关于UIScrollView事件
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了关于UIScrollView事件,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1508字,纯文字阅读大概需要3分钟。
内容图文

- (BOOL)touchesShouldCancelInContentView:(UIView *)view
Parameters
view |
The view object in the content that is being touched. |
view 这个view对象已获取到touched事件
Return Value
YES to cancel further touch messages to view, NO to have view continue to receive those messages.
The default returned value is YES if view is not a UIControl object; otherwise, it returns NO.
返回YES 在这个view上取消进一步的touched消息(不在这个view上处理,事件传到下一个view)。如果这个参数view不是一个UIControl对象,默认返回YES。如果是一个UIControl 对象返回NO.
The scroll view calls this method just after it starts sending tracking messages to the content view. If it receives NO from this method, it stops dragging and forwards the touch events to the content subview. The scroll view does not call this method if the value of the canCancelContentTouches property is NO.
scroll view调用这个函数,在发送taking消息到内容视图之后。如果返回NO,scroll view会停止拖动,触摸事件向子view传递。如果 canCancelContentTouches属性设置为NO 这个函数就不会调用
只有scrollView的canCancelContentTouches字段为YES 且 (BOOL)touchesShouldBegin:withEvent:inContentView:返回YES时,这个方法touchesShouldCancelInContentView:才会被调用。
什么情况下touchesShouldBegin返回YES呢? 在点击到scrollView上子视图的时候返回YES,表示让子视图也接收事件
touchesShouldCancelInContentView:
返回YES,表示当前view对这个事件不感兴趣,会传递到其他view
返回NO,scroll view会停止拖动,触摸事件交由该view处理或向子view传递。
总结:
在scroll view上添加一个button当在这个button上滑动的时候,scroll view并不会滑动,因为根据touchesShouldCancelInContentView:的解释该button是一个UIControl对象默认是返回NO。那么怎么能够实现在button上可以滑动scrollview呢?在touchesShouldCancelInContentView的时候返回YES,就可以了。
原文:http://www.cnblogs.com/HypeCheng/p/4721884.html
内容总结
以上是互联网集市为您收集整理的关于UIScrollView事件全部内容,希望文章能够帮你解决关于UIScrollView事件所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。