久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

為什么自定義的 MKMapView 注釋圖像在觸摸時會消失

Why does a custom MKMapView annotation image disappear on touch?(為什么自定義的 MKMapView 注釋圖像在觸摸時會消失?)
本文介紹了為什么自定義的 MKMapView 注釋圖像在觸摸時會消失?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在注釋我的地圖并設置圖像就好了,但是當我點擊 MapView 上的注釋時,圖像會從我的自定義圖像返回到紅色圖釘.這是為什么呢?

I am annotating my map and setting an image just fine, but when I tap the annotation on the MapView, the image goes from my custom image back to the red pin. Why is this?

- (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;
}

我的代碼看起來與一些不會產生此問題的示例代碼相同.

My code looks identical to some sample code that does not produce this problem.

推薦答案

在這里回答我自己的問題,以防其他人有同樣的問題.請注意,我正在使用MKPinAnnotationView" - 它應該更改為MKAnnotationView"并且一切正常.

Answering my own question here, just in case others have the same issue. Notice that I am using "MKPinAnnotationView" - it should be changed to "MKAnnotationView" and everything works.

固定代碼:

- (MKAnnotationView *)mapView:(MKMapView *)newMapView viewForAnnotation:(id )newAnnotation {
    MKAnnotationView *annotation = [[MKAnnotationView 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;
}

這篇關于為什么自定義的 MKMapView 注釋圖像在觸摸時會消失?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
How can i add more than 10 buttons on a navigationbar in iphone application development?(如何在 iphone 應用程序開發中的導航欄上添加 10 多個按鈕?)
Using UITouch inside a UIScrollView(在 UIScrollView 中使用 UITouch)
laying out images in UIScrollView automatically(自動在 UIScrollView 中布局圖像)
Scroll a background in a different speed on a UIScrollView(在 UIScrollView 上以不同的速度滾動背景)
主站蜘蛛池模板: 亚洲免费av一区 | 亚洲综合视频 | 精品欧美乱码久久久久久 | 欧美日韩视频在线 | 欧美中文字幕一区二区 | 香蕉视频久久久 | 极品粉嫩国产48尤物在线播放 | 日韩精品视频一区二区三区 | 日韩精品一区二区三区久久 | 黄网站在线播放 | 91精品久久久久久久久久入口 | 欧美日韩国产一区二区 | 99视频在线免费观看 | 久草视频在线播放 | 欧美精品一区二区三区四区五区 | 久久久久国产精品一区 | 亚洲久久一区 | 欧美一区二区另类 | 一级a爱片性色毛片免费 | 久久精品国产清自在天天线 | 精彩视频一区二区三区 | 欧美日本一区 | 看羞羞视频 | 欧美日韩在线一区二区 | 日韩美香港a一级毛片免费 国产综合av | 日韩av在线中文字幕 | 国产精品国色综合久久 | 日韩在线一区二区三区 | 欧美一级片在线观看 | 69xxx免费| 大乳boobs巨大吃奶挤奶 | 黄色网址免费在线观看 | 天天曰夜夜| 国产片侵犯亲女视频播放 | 亚洲精品久久久久国产 | 成人精品鲁一区一区二区 | 日韩精品一区二区三区在线播放 | 日本公妇乱淫xxxⅹ 国产在线不卡 | 日韩av网址在线观看 | 午夜天堂精品久久久久 | 五月激情综合网 |