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

為什么自定義的 MKMapView 注釋圖像在觸摸時(shí)會(huì)消失

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

問題描述

我正在注釋我的地圖并設(shè)置圖像就好了,但是當(dāng)我點(diǎn)擊 MapView 上的注釋時(shí),圖像會(huì)從我的自定義圖像返回到紅色圖釘.這是為什么呢?

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

我的代碼看起來與一些不會(huì)產(chǎn)生此問題的示例代碼相同.

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

推薦答案

在這里回答我自己的問題,以防其他人有同樣的問題.請(qǐng)注意,我正在使用MKPinAnnotationView" - 它應(yīng)該更改為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;
}

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

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

相關(guān)文檔推薦

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 應(yīng)用程序開發(fā)中的導(dǎo)航欄上添加 10 多個(gè)按鈕?)
Using UITouch inside a UIScrollView(在 UIScrollView 中使用 UITouch)
laying out images in UIScrollView automatically(自動(dòng)在 UIScrollView 中布局圖像)
Scroll a background in a different speed on a UIScrollView(在 UIScrollView 上以不同的速度滾動(dòng)背景)
主站蜘蛛池模板: 男人的天堂在线视频 | 国产精品久久精品 | 一区二区三区四区不卡视频 | 美女久久 | 成人精品一区二区三区中文字幕 | 亚洲免费在线观看 | 一本大道久久a久久精二百 国产成人免费在线 | 欧美日日| 国产精品美女久久久久aⅴ国产馆 | 在线中文一区 | 香蕉一区| 免费视频成人国产精品网站 | 亚洲国产一区在线 | 成人一级毛片 | 玖玖国产精品视频 | 欧美精品在欧美一区二区 | 三级黄片毛片 | 国产成人福利在线观看 | 国产一区二区三区四区三区四 | 久久精品久久久久久 | 国产精品成人一区二区三区吃奶 | 国产成人精品高清久久 | 日日日操 | 国产精品国产亚洲精品看不卡15 | 先锋资源站 | 欧美精品一区二区三区在线 | 免费h在线| 巨大荫蒂视频欧美另类大 | 可以免费观看的av片 | 亚洲一区二区中文字幕在线观看 | 国产一区二区视频免费在线观看 | 久久免费小视频 | 日韩精品久久久久 | 久久成人精品视频 | 国产精品精品视频一区二区三区 | 韩日一区 | av在线成人 | 精品国产91 | 一区二区视频在线观看 | 欧美成人不卡 | 亚州综合一区 |