8

我正在编写 UISwitch 替换(带有自定义图形)。我已经覆盖了 touchesMoved 和朋友,因此您可以在 Yes 和 No 之间拖动小部件,就像 UISwitch 一样。

如果将它放在滚动视图中,如果用户将手指沿对角线而不是完全水平移动最微小的一点,则触摸将被取消,并开始滚动。我注意到 UISwitch 和 UIButton 没有表现出这种行为,并且在操作这些控件时滚动永远不会启动。

How can I tell UIKit that I want exclusive control over these touches, in effect disabling scroll in touchesBegan and enabling scroll in ended/cancelled? I'm sure there's something obvious, but I've looked through the headers and documentation for UIControl, UIResponder, UIView and UIScrollView and haven't found anything.

Note: I don't want to make a UIScrollView subclass; I can't imagine that being the right solution, the control should be completely standalone.

4

1 回答 1

4

canCancelContentTouches = NO在滚动视图和exclusiveTouch = YES自定义控件中设置允许这种行为,假设您很高兴更改滚动视图上的属性。

于 2011-03-22T11:28:57.620 回答