0
votes

I have a subview UIbutton with frame (4,8),(13,13).

Touch A is at position (4,16) relative to superview, but gets sent to the superview, even though its within the button bounds. In window coordinates this is (49,131).

Touch B occurs one pixel left with window coordinates of (48,131) but gets sent to the subview button, even though it's out of bounds. The view reports a (-1,7) position in the UIButton.

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

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

The superview does not implement a custom pointInside method.

How is it that the touch out of bounds of the subview can be forwarded to the subview and the touch that is in bounds of the subview is forwarded to the superview?

1

1 Answers

0
votes

Not a solution, but a workaround to my own question.

This strange behavior appears to occur with buttons that are too small, in this case its 13x13. Expanding the button size (and using contentInsent for image placement), increased the touchable area (in this case expanding it to 43 pixels wide) to about half the button.