我有一个自定义表格单元,其中嵌入了 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/