gpt4 book ai didi

ios - UITableViewCell 中点击的 MKMapView 的详细信息

转载 作者:行者123 更新时间:2023-11-28 21:49:08 24 4
gpt4 key购买 nike

在我的 ios 应用程序中,TableView 中的每个单元格上都有一个 MapView(每个单元格都有单独的点)。当用户点击 MKMapView 时,应用程序应该转到另一个 UIViewcontroller,全屏显示 MKMapView,如果它发生在其他地方单元格,它应该转到“详细信息”页面。但是我无法让程序识别点击是否发生在 MapView 的框架内。我尝试了 -touchesBegan,但控件甚至没有到达该方法。有人可以帮帮我吗?

最佳答案

您可以创建自定义 UIView 并将 mapView 添加为它的 subview ,并将 userInteractionEnabled 设置为 NO。现在您可以使用 UIGestureRecognizer 来检测触摸。

UITapGestureRecognizer *sigleTap = [[UITapGestureRecognizer alloc] 
initWithTarget:self action:@selector(handleGesture:)];
sigleTap.numberOfTapsRequired = 1;
sigleTap.numberOfTouchesRequired = 1;
[yourCustomView addGestureRecognizer:sigleTap];


- (void)handleGesture:(UIGestureRecognizer *)gestureRecognizer
{
your next logic
}

关于ios - UITableViewCell 中点击的 MKMapView 的详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28960028/

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