gpt4 book ai didi

IOS uimap 单击 subview 中的标注按钮

转载 作者:行者123 更新时间:2023-11-29 03:09:17 25 4
gpt4 key购买 nike

我正在创建一个使用 uimap - IOS 应用程序的应用程序。我创建了一个标注注释,它从 nib 文件加载并将其添加为 subview 。现在我在 nib 文件中添加了一个按钮,当单击 subview 中的按钮时我无法获取事件。

如何在单击 subview 中的按钮时触发事件?

谢谢。

最佳答案

@implementation YourViewController

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
CalloutView *calloutView = however you load it from nib;
calloutView.button.tag = some unique id;
[button addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
return calloutView;
}

- (void)showDetails:(UIButton *)sender
{
NSLog(@"Button tag: %i was pressed", sender.tag);
}
@end

关于IOS uimap 单击 subview 中的标注按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22391625/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com