Я следую этому руководству (http://icodeblog.com/2009/12/21/introduction-to-mapkit-in-iphone-os-3-0/) при добавлении mapkit и аннотаций в приложение. Однако я серьезно борюсь с расположением пользователя. Я новичок в xcode, поэтому не совсем уверен, что делатьЗатем я попробовал вариант Тони:
step one: add the CoreLocation framework to the project.
Step two: add this function to the iCodeMapViewController.m:
- (void)setCurrentLocation:(CLLocation *)location {
MKCoordinateRegion region = {{0.0f, 0.0f}, {0.0f, 0.0f}};
region.center = location.coordinate;
region.span.longitudeDelta = 0.15f;
region.span.latitudeDelta = 0.15f;
[self.mapView setRegion:region animated:YES];
}
step three: add this code to the ViewForAnnotation Method:
if (annotation != mapView.userLocation) {
//the rest of the ViewForAnnotation code goes here
}else{
CLLocation *location = [[CLLocation alloc]
initWithLatitude:annotation.coordinate.latitude
longitude:annotation.coordinate.longitude];
[self setCurrentLocation:location];
}
Но когда я иду на сборку, мне это не нравится.
Я также пробовал этот вариант:
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation
{
if ([annotation isKindOfClass:MKUserLocation.class]) return nil;
//rest of code
}
Синяя точка показывает, мои пользовательские аннотации показывают, но приложение падает, когда я пытаюсь прокрутить таблицу. Отладчик не помогает, но останавливается на этом утверждении.
Может кто-нибудь помочь?Примеры кода тоже? Я думаю, что ответ на этот пост может быть полезным для ряда людей, также борющихся с mapkit.
Приветствия