我正在创建一个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,直到你点击它并出现。
严重的是我遇到的更奇怪的问题之一。
如果你在我面前,我会吻你。非常感谢你抽出时间帮助我解决这个问题。 另外,两年前,我去看了安娜卡列尼娜,并喜欢它。现在我已经说过了,我希望你没有选择那个用户名,因为你认为这个节目很荒谬,哈哈。 再次感谢。 –