我需要帮助MKMapView。在地图我显示图片点击图片后显示popUp wih最大的图片和标题(AnnotationView)但我不能添加任何按钮......他们只是不工作。然后我尝试这个
cancelButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[cancelButton setImage:[UIImage imageNamed:@"map_dialog_cancel.png"] forState:UIControlStateNormal];
[cancelButton setFrame:CGRectMake(0.0 , 0.0, 25.0, 25.0 )];
[cancelButton addTarget:self action:@selector(cancelButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
self.leftCalloutAccessoryView = cancelButton;
self.canShowCallout = YES;
但是现在用自定义弹出窗口上方的按钮开始显示标准弹出窗口...如何在弹出窗口中放置关闭按钮?
答案 0 :(得分:0)
ok问题解决了你在AnnotationView类中添加的所有内容
-(UIView*)hitTest:(CGPoint)point withEvent:(UIEvent*)event
{
[super hitTest:point withEvent:event];
if (point.x > buttonFrame.origin.x && point.y > buttonFrame.origin.y && point.x < buttonFrame.origin.x +buttonFrame.size.width && point.y < buttonFrame.origin.y +buttonFrame.size.height)
{
NSLog(@"handlePinButtonTap: ");
[delegate closePopUpPressed:self];
}
return nil;
}
谁有更好的解决方案请写在这里