2016年5月25日 星期三

UIScrollView裡面的點擊事件反應很慢

var delaysContentTouchesBool

If the value of this property is true, the scroll view delays handling the touch-down gesture until it can determine if scrolling is the intent. If the value is false , the scroll view immediately callstouchesShouldBegin:withEvent:inContentView:. The default value is true.

同樣一個UISegmentedControl,加在ScrollView裡面反應就異常的慢,原來是UIScrollView的subview上的touch事件會被延遲,目的是為了確定當次的手勢不是要滑動。
如果你想讓你的scrollView以點擊事件為主:
yourScrollView.delaysContentTouches = false
如果你想讓你的scrollView以滑動事件為主:
yourScrollView.delaysContentTouches = true

沒有留言:

張貼留言