我正在創建一個MKAnnotationView與詳細信息泄露按鈕。UIButton無法正確加載MKAnnotationView
在mapView:viewForAnnotation:我只是創建一個佔位符按鈕。
// the right accessory view needs to be a disclosure button ready to bring up the photo
aView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
在圖形頁面:didSelectAnnotationView:其實我創建要使用(連同有關標籤)按鈕
// create a button for the callout
UIButton *disclosure = [self.delegate mapController:self buttonForAnnotation:aView.annotation];
NSLog(@"DisclosureButton: %@", disclosure);
// set the button's target for when it is tapped upon
[disclosure addTarget:self.delegate action:@selector(presentAnnotationPhoto:) forControlEvents:UIControlEventTouchUpInside];
// make the button the right callout accessory view
aView.rightCalloutAccessoryView = disclosure;
在日誌中,該按鈕似乎完全實例化,以及設置與正確的標籤。
這是按鈕造物主:
/**
* returns an button for a specific annotation
*
* @param sender the map controller which is sending this method to us (its' delegate)
* @param annotation the annotation we need to create a button for
*/
- (UIButton *)mapController:(MapController *) sender
buttonForAnnotation:(id <MKAnnotation>) annotation
{
// get the annotation as a flickr photo annotation
FlickrPhotoAnnotation *fpa = (FlickrPhotoAnnotation *)annotation;
// create a disclosure button used for showing photo in callout
UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
// associate the correct photo with the button
disclosureButton.tag = [self.photoList indexOfObject:fpa.photo];
return disclosureButton;
}
當我選擇註釋的問題就來了。幾秒鐘後,當選擇註釋並點擊詳細披露按鈕時,不會發生任何事情。但是,在敲幾下註釋並測試按鈕後,它最終按預期工作。
奇怪的延遲是怎麼回事?有時,當按鈕開始工作時,它看起來好像是alpha被設置爲0.0,直到你點擊它並出現。
嚴重的是我遇到的更奇怪的問題之一。
如果你在我面前,我會吻你。非常感謝你抽出時間幫助我解決這個問題。 另外,兩年前,我去看了安娜卡列尼娜,並喜歡它。現在我已經說過了,我希望你沒有選擇那個用戶名,因爲你認爲這個節目很荒謬,哈哈。 再次感謝。 –