解决ScrollView设置delaysContentTouches为NO后,按在button上scrollview无法滑动问题
来源:互联网 发布:深圳市建筑工务署 知乎 编辑:程序博客网 时间:2024/06/06 08:24
解决ScrollView设置delaysContentTouches为NO后,按在button上scrollview无法滑动问题
分类:
版权声明:本文为博主原创文章,未经博主允许不得转载。
在ScrollView中如果添加了button,一开始会出现button的按下效果不明显,此时会设置scrollView.delaysContentTouches = NO;来关闭延迟响应, 但是又会出现手指放在button上去做滑动,但是scrollView只会响应button的点击事件,而不去进行滑动.
要解决这个办法,需要重载UIScrollView这个类,并实现其中的touchesShouldCancelInContentView:方法,在方法中return YES就好啦.
但是会有人发现,为什么我重载了这个方法,但是打了断点却发现不调用这个方法呢?
看下外国友人的问答:
From what I've seen, you don't get touchesShouldCancelInContentView: or touchesShouldBegin:withEvent:inContentView: callbacks unless you have delaysContentTouches set to NO:
scrollView.delaysContentTouches = NO;这段说你重载的这俩方法,必须同时设置scrollView.delaysContentTouches = NO;
I got stuck on this for a while incase you ever read this, you need to have both the following properties set before touches in touchesShouldCancelInContentView will fire
scrollView.delaysContentTouches = NO;
scrollView.canCancelContentTouches = YES;
Just having scrollView.delaysContentTouches = NO wont fire if scrollView.canCancelContentTouches = NO
下边又回复说,必须同时设置以下两个才可以:
scrollView.delaysContentTouches = NO;
scrollView.canCancelContentTouches = YES;
验证好使,快来试试吧~
- 顶
- 0
0 0
- 解决ScrollView设置delaysContentTouches为NO后,按在button上scrollview无法滑动问题
- 解决ScrollView设置delaysContentTouches为NO后,按在button上scrollview无法滑动问题
- scrollView中放满button,无法滑动
- scrollView无法滑动问题
- scrollview上添加button 滑动botton区域无法实现scrollview滑动的解决方法
- 如何解决ViewPager在ScrollView中滑动经常失效、无法正常滑动问题。
- 解决当最下层为ScrollView时,ScrollView上层View上的button点击动画延迟问题
- activity添加ScrollView后或外部容器为RelativeLayout时onFling不起作用,无法滑动问题
- 参考解决iOS7中scrollView设置了contentSize后仍然不能滑动的问题
- activity添加ScrollView后onFling不起作用,无法滑动问题
- 解决ScrollView中嵌套EditText无法滑动的问题
- 解决ScrollView嵌套RecyclerView无法滑动的问题
- Android 解决 ScrollView 嵌入 HorizontalScrollView 后滑动卡顿问题
- Android之解决scrollview总是优先滑动,导致在scrollview内的控件不滑动问题
- 解决在scrollview上下滑动嵌套scrollview,viewpager水平滑动时的抖动问题
- 解决在scrollview上下滑动嵌套scrollview,viewpager水平滑动时问题
- Android之解决scrollview总是优先滑动,导致在scrollview内的控件不滑动问题
- 解决在scrollview上下滑动嵌套scrollview,viewpager水平滑动时的抖动问题
- 大数据系列修炼-Scala课程104
- 黑盒测试用例设计方法
- ubuntu下ndk的安装和使用
- Studio系列、Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
- spark2.0 on mesos1.0.1
- 解决ScrollView设置delaysContentTouches为NO后,按在button上scrollview无法滑动问题
- C#类中字段field_161019
- Android 开发常识
- IOS中的视图基本方法(新手篇)
- C++“准”标准库Boost学习指南(5):正则表达式库 Boost.Regex
- git 格式化输出版本信息
- MFC鼠标移动到按钮上显示其他形状
- Android APK加壳技术方案
- jQuery之Deferred解读