开发者

Select tablecell when touching embedded view

开发者 https://www.devze.com 2022-12-19 20:26 出处:网络
I have a custom tablecell with an embedded MapView showing a small area. When the user selects the cell, I want to push a new view with a larger mapview and some more information, like distance from w

I have a custom tablecell with an embedded MapView showing a small area. When the user selects the cell, I want to push a new view with a larger mapview and some more information, like distance from where you are, option of what map-type e开发者_StackOverflow中文版tc.

If I leave a small margin around my mapview, the user can click in that margin to select the cell, but how can I make the cell selected if they click inside the mapview?

regards,

-Vegar


I think you need to override the hitTest method inherited from UIView

- (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.


Try set MapView's userIteractionEnabled property to NO

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号