[MonoTouch] Issue with MKMapView selected annotations
Geoff Norton
gnorton at novell.com
Fri Nov 6 22:44:45 EST 2009
Chris,
I'm pretty sure I know what the issue here is, but could you file a
bug with a testcase so I can confirm and get it fixed?
Thanks
Geoff
On 6-Nov-09, at 10:26 PM, Chris Bailey wrote:
> I am continuing to have an issue that I am wondering if anyone has
> an idea about. In my code, I would like to obtain the coordinates
> of the current selected annotation from MKMapView. To do this, I
> have attempted:
>
> CLLocationCoordinate2D desiredlocation =
> mapView.SelectedAnnotations.First().Coordinate;
>
> With this code, everything compiles OK, however, I always get a
> cannot cast from source to destination type error.
>
> Unhandled Exception: System.InvalidCastException: Cannot cast from
> source type to destination type.
> at (wrapper managed-to-native)
> object:__icall_wrapper_mono_object_castclass (object,intptr)
> at MonoTouch.Foundation.NSArray.ArrayFromHandle[MKAnnotation]
> (IntPtr handle) [0x00000]
> at MonoTouch.MapKit.MKMapView.get_SelectedAnnotations () [0x00000]
> at Martini.AppDelegate+MapViewDelegate
> +<GetViewForAnnotation>c__AnonStorey1.<>m__6 (System.Object ,
> System.EventArgs ) [0x00000]
> at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000]
> at (wrapper managed-to-native)
> MonoTouch.UIKit.UIApplication:UIApplicationMain
> (int,string[],intptr,intptr)
> at MonoTouch.UIKit.UIApplication.Main (System.String[] args,
> System.String principalClassName, System.String delegateClassName)
> [0x00000]
> at MonoTouch.UIKit.UIApplication.Main (System.String[] args)
> [0x00000]
> at Martini.Application.Main (System.String[] args) [0x00000]
>
> Does anyone have an idea how to accomplish what I am desiring?
>
> Monotouch 1.2 with latest MonoDevelop.
>
> Thanks!
> Chris
> _______________________________________________
> MonoTouch mailing list
> MonoTouch at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch
More information about the MonoTouch
mailing list