相关疑难解决方法(0)

为什么自定义MKMapView注释图像在触摸时会消失?

我正在注释我的地图并设置好图像,但是当我点击MapView上的注释时,图像会从我的自定义图像返回到红色图钉.为什么是这样?

- (MKAnnotationView *)mapView:(MKMapView *)newMapView viewForAnnotation:(id )newAnnotation {
    MKPinAnnotationView *annotation = [[MKPinAnnotationView alloc] initWithAnnotation:newAnnotation reuseIdentifier:@"currentloc"];
    if (annotation == nil) {
        annotation = [[MKAnnotationView alloc] initWithAnnotation:newAnnotation reuseIdentifier:@"currentloc"];
    }

    annotation.image = [UIImage imageNamed:@"anno.png"];
    annotation.canShowCallout = YES;
    annotation.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bus_stop_30x30.png"]];
    annotation.leftCalloutAccessoryView = imgView;

    return annotation;
}
Run Code Online (Sandbox Code Playgroud)

我的代码看起来与一些不会产生此问题的示例代码相同.

iphone annotations mapkit

6
推荐指数
1
解决办法
6692
查看次数

iPhone核心位置:当地图类型更改时,自定义图钉图像会消失

我有一个分段控制器,它位于MKMapView上.当我更改MKMapType时,我的自定义引脚的图像将恢复为默认的红色.标题和副标题以及坐标保持不变.任何人都可以对可能的解决方案有所了解吗?

iphone core-location

5
推荐指数
1
解决办法
1679
查看次数

标签 统计

iphone ×2

annotations ×1

core-location ×1

mapkit ×1