Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Event registration is overwriting existing delegate. Either just use events or your own delegate: Xamarin.Forms.Maps.iOS.MapDelegate MapKit.MKMapView+_MKMapViewDelegate
- Update Xamarin Studio and iOS (at least) with the latest releases from the beta channel
- Create a new Xamarin.Forms solution with at least support for iOS
- Add Xamarin.Forms.Maps using the nuget package manager
- Add initialization code in the AppDelegate (global::Xamarin.FormsMaps.Init ();)
- Add a map to the default Xamarin Forms page
- Run the project using the iOS simulator
Observe that you get the error message above.
**Note:** The reason for this seems to be that the Xamarin.Forms Maps Renderer for iOS sets both the RegionMoved event and the Map delegate in its OnElementChanged method. This causes a test to fail in Xamarin iOS that tries to prevent us from use events and delegates at the same time when handling map events.
Created attachment 10800 [details]
Project with reproduction under iOS 8.10
Many thanks for the report!
I was able to reproduce this issue with:
But happily, it looks like the problem is fixed in the latest pre-release versions:
I updated these packages in both the "TestinMaps.iOS" and "TestinMaps" project in the attached test case, and rebuilt the app. After that, the app ran without error and displayed a map (tested on iPhone 4, iOS 7.2.1 and iPhone 5s Simulator, iOS 8.1).
Be sure to let us know if the 1.4.2-pre2 versions do not address the problem when you try them. Thanks!
Typo correction: tested on iPhone 4, iOS 7.1.2
I tried to upgrade the project, but still experienced the same problem (updated to 188.8.131.5253-pre2 of both Xamarin.Forms and Xamarin.Forms.Maps).
If you open the Assembly Browser and look up the class Xamarin.Forms.iOS.MapRenderer, you will see that it still sets both the RegionChanged event and the map delegate. This is the cause of the bug.
Thanks for the investigation! In 184.108.40.20649, I do indeed see assignments to both:
- The `MKMapView.RegionChanged` event.
- The `MKMapView.Delegate` property.
Both of these assignments appear in the `MapRenderer.OnElementChanged()` method.
In "Xamarin.Forms.Maps.iOS" 220.127.116.1153-pre2, I do _not_ see the same conflict. Instead I see:
- An assignment to the `MKMapView.RegionChanged` event, as before.
- A _new_ assignment to the `MKMapView.GetViewForAnnotation` property.
Both of these assignments use the `MKMapView.EnsureMKMapViewDelegate()` method behind the scenes, so I believe they should be compatible with each other. And that would explain why the app runs successfully on 1.4.2-pre2 in my quick tests. On the other hand, I might be missing some slightly more complicated usage pattern with the map that can still trigger this behavior using 1.4.2-pre2. Right now I've just been letting the map load on the simulator, and then zooming and panning around a little.
## Additional notes
It looks like this part of the code was adjusted to fix bug 25557. Admittedly, it sounds like there's a case where removing and re-adding Pins still does not work as expected related to bug 25557, so perhaps those code fixes still need further adjustment.
I will leave this bug open so that:
A. The QA team can double-check which behaviors they see with 18.104.22.16849 vs. 22.214.171.12453-pre2.
B. The Xamarin.Forms developers can chime in with any additional notes to confirm the expected behavior in 126.96.36.19953-pre2 and later.
Xamarin Customer Support
I have checked this issue and observed that
The application throw exception with Xamarin.Forms version 188.8.131.5249 and Xamarin.Forms.Maps 184.108.40.20649.
Screencast for the same: http://www.screencast.com/t/MnXhYAPvJ6r8
The application is working fine with Xamarin.Forms version 220.127.116.1155 and Xamarin.Forms.Maps 18.104.22.16855.
Screencast for the same: http://www.screencast.com/t/slyY6gocGQN
The application also wotking fine with Xamarin.Forms version 22.214.171.12456-pre1