含有按钮的ScrollView在iOS8中无法滚动的解决办法 | ScrollView with UIControl/UIButton subviews not scrollable under iO...

本文介绍了解决 iOS 8 中 UIScrollView 在包含 UIButton 子视图时无法正常滚动的问题。通过设置 scrollView.panGestureRecognizer.delaysTouchesBegan 属性为 YES 或采用其他工作方式,可以有效解决该问题。

转自:http://zcw.me/blogwp/%E5%90%AB%E6%9C%89%E6%8C%89%E9%92%AE%E7%9A%84scrollview%E5%9C%A8ios8%E4%B8%AD%E6%97%A0%E6%B3%95%E6%BB%9A%E5%8A%A8%E7%9A%84%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95-scrollview-with-uicontroluibutton-subv/

 

origin:http://stackoverflow.com/questions/26008559/scrollview-with-uicontrol-uibutton-subviews-not-scrollable-under-ios-8

这样设置就可以了:

Searched for a while and got this issue fixed by

scrollview.panGestureRecognizer.delaysTouchesBegan = YES;

—————————————————————
另外:

I found that in iOS 8, the UIScrollView's underlying UIPanGestureRecognizer is not respecting the UIScrollView's delaysContentTouches property. I consider this an iOS 8 bug. Here's my workaround:

theScrollView.panGestureRecognizer.delaysTouchesBegan = theScrollView.delaysContentTouches

And there's also another workaround (but I tried without lucky, cause UIControl instances not works then, let me know if u've any idea about it, thx):

if (floor((NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1)) { UITapGestureRecognizer * nothingTap = [[UITapGestureRecognizer alloc] init]; [nothingTap setDelaysTouchesBegan:YES]; [scrollView addGestureRecognizer:nothingTap]; }

再另外,还可以写一个继承UIScrollView的子类:
见http://stackoverflow.com/questions/25800325/ios-8-buttons-in-horizontal-scroll-view-intercepting-pan-event-scroll-does-n
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值