0

I have a weird issue with MKMapView's callout view. I am using leftCalloutAccessoryView to set up a view that holds an image and a couple of labels as shown in the picture below. Whenever I tap the annotation, the animation that normally shows the callout appears and then the my content disappears and reappears by sliding from the left side as shown in the gif image. I don't know how to fix this. This only happens on iOS 8. It appears fine on iOS 7.

callout animation

4

1 回答 1

1

我自己想通了。所以我只是发布这个来帮助任何遇到同样问题的人。问题在于我如何返回leftCalloutAccessoryView. 我正在覆盖该方法并UIView通过在那里分配它来返回 a 。那是由于某种原因导致动画。我创建了一个新属性并初始化了附件视图并leftCalloutAccessoryView每次都返回相同的对象。这解决了问题。

@property (nonatomic, strong) UIView *accessory;

-(UIView *)leftCalloutAccessoryView {
    return self.accessory;
}

-(UIView *)accessory {
    if (_accessory == nil) {
        UIView *backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.mapView.frame.size.width-8, height)];
        // custom code here
        _accessory = backgroundView;
    }
    return _accessory;
}

做这一切解决了这个问题。

于 2015-03-02T07:29:51.297 回答