5

我的理解是迁移到 iOS 6 地图没有问题。但是由于某种原因,我的地图应用程序中现在缺少详细信息披露按钮。有没有办法把这个找回来。哇,完全出乎意料。这已经工作了多年,所以所有代表都很好。

#pragma mark MKMapViewDelegate
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {

MKPinAnnotationView *pin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"REUSEME"] autorelease];
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

if ([annotation isKindOfClass:[MKUserLocation class]]) {
    pin.animatesDrop = YES;
    return nil;
} else {
    [pin setPinColor:MKPinAnnotationColorGreen];
}

pin.rightCalloutAccessoryView = button;
pin.animatesDrop = YES;
pin.canShowCallout = YES;

return pin;
}
4

9 回答 9

2

现在在 iOS 6 中,您必须在将注释添加到 mapView 之前设置委托

在这里看到:http ://www.openradar.me/12346693

于 2012-11-22T23:16:52.033 回答
2

我遇到了同样的问题,在 Storyboard 中设置 MapView 委托对我来说很有效,标注箭头现在可以工作了:)

于 2012-10-22T03:22:32.063 回答
2

我遇到了同样的问题,我只在注释之后放置了委托并且完美地工作!

mapView.delegate = self;
[self.mapView addAnnotation:ann];

Tks, 考卡

于 2013-03-22T00:47:55.653 回答
0

@ErCa 根据 iOS 文档,除非您正在构建自定义视图,否则您永远不应该调用 loadView。

问题出在其他地方。我也有它,一旦找到它就会发布答案。

@ed-potter 你的目标是 iOS4 吗?我问是因为您自动释放 MKPinAnnotationView,这对于 ARC 来说是不必要的。

于 2012-09-29T13:40:55.963 回答
0

这也发生在我身上。确实,由于某种原因,现在需要在 viewDidLoad: 之前设置 MKMapView 委托。我最终做的是在我的 setMapView: 函数中设置 mapView 委托。

所以对于包含 MKMapView 的视图控制器,我有以下属性:

@property(非原子,弱)IBOutlet MKMapView *mapView;

所以我把 setMapView 函数:

-(void)setMapView:(MKMapView *)mapView {

_mapView = mapView;

self.mapView.delegate = self;//needed to move setting of the mapView delegate here because they changed when the viewForAnnotations delegate function is called when Apple went to iOS 6 and changed the maps App.  Now all of the annotations are loaded and the views for those annotations are set up before the View Controller even calls viewDidLoad.

[self updateMapView];

}

于 2012-09-30T19:53:48.553 回答
0

我没有这个问题,我在你的代码和我的代码之间看到的唯一区别是在创建 MKPinAnnotationPinView 对象时,我首先尝试将其出列:

    MKPinAnnotationView *pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"CustomPinAnnotationView"];
于 2012-09-20T12:34:29.573 回答
0

我在 iOS 6 的 mapKit 中注意到的是时间是必不可少的。将 MKMapView 的委托设置为延迟(即在 viewDidLoad 中),地图将对已添加的注释使用默认注释样式。我的解决方案是将 mapView.delegate = self 移动到 -(void)loadView 方法。

于 2012-09-24T10:47:07.107 回答
0

我有同样的问题,我使用与第一个答案相同的代码:

MKPinAnnotationView *MyPin =(MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"MyPin"];

我还注意到更新到 xcode 4.5/iOS 6 后的其他问题。

于 2012-09-22T23:12:42.540 回答
0

self.mapView.delegate = self我遇到了同样的问题,也在设置viewDidLoadmapView:viewForAnnotation:没有被调用,所以我leftCalloutAccessoryView没有得到UIImageView我指定的。我回去复习了 Ray Wenderlich在 iOS 6 教程中的 MapKit 简介,发现:

首先选择 MainStoryboard.storyboard。然后通过控制点击地图视图,将视图控制器(位于列表顶部的右侧)设置为地图视图的委托,并从委托条目拖动一条线到视图控制器。

于 2012-11-04T14:37:48.747 回答