【问题标题】:Problems with AnnotationView and Close buttonAnnotationView 和关闭按钮的问题
【发布时间】:2012-03-12 16:37:05
【问题描述】:

我需要 MKMapView 的帮助。在地图中,我在点击图片后显示图片,显示带有最大图片和标题(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;

但是现在开始在我的自定义弹出窗口上方显示带有按钮的标准弹出窗口...如何在弹出窗口中放置关闭按钮?

【问题讨论】:

  • 当系统允许时,将您的解决方案放在这里作为答案。您可以在适当的时候接受答案。

标签: iphone annotations popup mkmapview mkannotationview


【解决方案1】:

好的问题解决了所有你需要在你的 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;
}

谁有更好的解决方法请写在这里

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-03
    相关资源
    最近更新 更多