2012-05-07 95 views
0

我有一個帶有框架(4,8),(13,13)的子視圖UIbutton。iOS UIButton在框架外接收觸摸,但不在框架內

觸摸A在位置(4,16)相對於superview,但被髮送到超級視圖,即使它在按鈕範圍內。在窗口座標中,這是(49,131)。

觸摸B發生一個像素,窗口座標爲(48,131),但發送到子視圖按鈕,即使它超出邊界。該視圖報告UIButton中的(-1,7)位置。

觸摸甲

<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} 

觸摸乙

<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} 

的上海華不實現自定義pointInside方法。

它是如何觸摸越界的子視圖可以轉發到子視圖,並在子視圖邊界的觸摸轉發到超級視圖?

回答

0

不是一個解決方案,而是解決我自己的問題。

這種奇怪的行爲似乎發生在按鈕太小,在這種情況下,它是13x13。擴大按鈕尺寸(並使用contentInsent進行圖像放置),增加了可觸摸區域(在這種情況下,將其擴大到43個像素寬)至大約一半的按鈕。