[MonoTouch] Issue with MKMapView selected annotations
Chris Bailey
chris at mybnetworks.com
Fri Nov 6 22:26:40 EST 2009
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monotouch/attachments/20091106/cafc472f/attachment.html
More information about the MonoTouch
mailing list