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

转自: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

你可能感兴趣的:(scrollview)