简体   繁体   中英

Invalid UserLocation iPhone MapKit

I am trying to set the mapView's center coordinate to be the users location:

[self.mapView setCenterCoordinate:[[[self mapView] userLocation] coordinate]];

However I am getting a crash which is to do with the user location being invalid:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid Coordinate -180.00000000, -180.00000000'

Has anyone else had this error before? Or do you know how to fix this?

Turns out you need to get the [[[[self mapView] userLocation] location] coordinate] rather than the mapView's userLocation's coordinate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM