0

我有一个带有框架(4,8),(13,13)的子视图 UIbutton。

触摸 A 位于相对于 superview 的位置 (4,16),但被发送到 superview,即使它在按钮范围内。在窗口坐标中,这是 (49,131)。

触摸 B 发生在窗口坐标为 (48,131) 的左侧一个像素,但被发送到子视图按钮,即使它超出了边界。视图报告 UIButton 中的 (-1,7) 位置。

触摸A

<UITouch: 0x7b2ddeb0> phase: Ended tap count: 1 
window: <DebugWindow: 0x791357f0; baseClass = UIWindow; frame = (0 0; 320 480); layer = <UIWindowLayer: 0x791358d0>> 
view: <QueueOverlayCellView: 0x7b1ca320; frame = (2 2; 269 30); tag = 1; layer = <CALayer: 0x7b1ca3a0>> 
location in window: {49, 131} previous location in window: {49, 131} 
location in view: {4, 16} previous location in view: {4, 16}

触摸 B

<UITouch: 0x7b442e90> phase: Ended tap count: 1 
window: <DebugWindow: 0x791357f0; baseClass = UIWindow; frame = (0 0; 320 480); layer = <UIWindowLayer: 0x791358d0>>
view: <TableButton: 0x7b1cada0; baseClass = UIButton; frame = (4 8; 13 13); opaque = NO; layer = <CALayer: 0x7b1cae40>> 
location in window: {48, 130} previous location in window: {48, 130}
location in view: {-1, 7} previous location in view: {-1, 7}

superview 没有实现自定义的 pointInside 方法。

如何将超出子视图边界的触摸转发到子视图,而将子视图边界内的触摸转发到父视图?

4

1 回答 1

0

不是解决方案,而是解决我自己的问题的方法。

这种奇怪的行为似乎发生在太小的按钮上,在本例中为 13x13。扩大按钮大小(并使用 contentInsent 放置图像),将可触摸区域(在本例中将其扩大到 43 像素宽)增加到按钮的一半左右。

于 2012-05-08T22:45:08.240 回答