iphone - 触摸嵌入 View 时选择表格单元格

标签 iphone cocoa-touch uitableview mkmapview

我有一个自定义表格单元,其中嵌入了 map View ,显示了一个小区域。当用户选择单元格时,我想推送一个具有更大 map View 和更多信息的新 View ,例如距您所在位置的距离、 map 类型的选项等。

如果我在 map View 周围留下一个小边距,用户可以单击该边距来选择单元格,但是如果他们在 map View 内单击,如何才能选择单元格?

问候,
-素食

最佳答案

我认为你需要重写从 UIView 继承的 hitTest 方法

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event

This method traverses the view hierarchy by sending the pointInside:withEvent: message to each subview to determine which subview should receive a touch event. If pointInside:withEvent: returns YES, then the subview’s hierarchy is traversed; otherwise, its branch of the view hierarchy is ignored. You rarely need to invoke this method, but you might override it to hide touch events from subviews.

关于iphone - 触摸嵌入 View 时选择表格单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2229271/

相关文章:

iphone - 如何在不使用 NSTimer 的情况下在 iPhone 上循环游戏

iphone - 转换矩形 :toView: works different on iPad retina and iPad 2

iphone - UITableView 钩子(Hook)方法的调用顺序是什么?

iphone - UITableViewController.view 崩溃

iphone - 在iPhone中哪里使用scrollToRowAtIndexPath?

iphone - 如何为 iOS 私有(private) api (MobileWifi.framework) 添加授权

iphone - UIToolbar 项目未显示

objective-c - CoreLocation kCLErrorDomain 错误 5

ios - 删除单元格后更新标签

iphone - 为什么执行选择器:withObject: methods can only take id?