Tôi đang cố sử dụng chế độ xem chú thích bản đồ tùy chỉnh khá đơn giản và chú thích - chế độ xem chú thích khi tạo, chỉ thêm UIImageView làm chế độ xem phụ. Điều đó hoạt động tốt.Ngoại lệ MKMapKit khi sử dụng canShowCallout trên chế độ xem chú thích
Tuy nhiên, khi tôi gọi canShowCallout trên chế độ xem chú thích, Một ngoại lệ được ném vào MapKit ngay sau khi trả lại chế độ xem. Sự kết thúc của ngăn xếp trông giống như:
#0 0x94e964e6 in objc_exception_throw
#1 0x01e26404 in -[MKOverlayView _addViewForAnnotation:]
#2 0x01e22037 in -[MKOverlayView _addViewsForAnnotations:animated:]
#3 0x01e1ddf9 in -[MKOverlayView showAddedAnnotationsAnimated:]
#4 0x01df9c0e in -[MKMapView _showAddedAnnotationsAndRouteAnimated:]
#5 0x01e0371a in -[MKMapView levelView:didLoadTile:]
My viewForAnnotation là khá đơn giản:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if (! [annotation isKindOfClass:[MyAnnotation class]])
return nil;
MyAnnotationView *useView = (MyAnnotationView *)[myMapView dequeueReusableAnnotationViewWithIdentifier:@"resuseview"];
if (useView == nil)
{
useView = [[[MyAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"resuseview"] autorelease];
useView.canShowCallout = YES; // if commented out view appears just fine
}
else
{ useView.annotation = annotation; }
return useView;
}
Như đã đề cập trong các mã, quan điểm chú thích hoạt động tốt như là - cho đến khi tôi thêm canShowCallout, sau đó nó bị treo lần đầu tiên bản đồ được xem.
cảm ơn bạn Kendall –