ios 8 - 水平滚动视图中的按钮拦截平移事件 - 滚动不起作用

ios 8 - buttons in horizontal scroll view intercepting pan event - scroll does not work(ios 8 - 水平滚动视图中的按钮拦截平移事件 - 滚动不起作用)
本文介绍了ios 8 - 水平滚动视图中的按钮拦截平移事件 - 滚动不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个带有一行按钮的水平滚动视图.除非我非常快速地滑动,否则滚动视图不会滚动.

I have a horizontal scroll view with a line of buttons. The scroll view will not scroll unless I do an extremely fast swipe.

如果我将按钮设置为 userInteractionEnabled = NO,则滚动按预期工作,但当然,按钮根本不起作用.

If I set the buttons to userInteractionEnabled = NO, then the scrolling works as expected, but of course, then the buttons don't work at all.

此应用在 iOS 7 及之前的版本中运行良好.这似乎是 iOS 8 的功能".我确实注意到我可以捕获按钮的拖动事件,但我不知道如何将其重定向回滚动视图.

This app worked fine in iOS 7 and before. It seems to be a iOS 8 "feature". I did notice that I can catch the button's drag event, but I don't know how to redirect it back to the scrollView.

我想我需要用 UIView 替换我的按钮并自己管理事件,但如果有人有其他想法或解决方案,我将不胜感激.

I'm thinking I'll need to replace my buttons with UIViews and manage the events myself but I'd be grateful if someone has other ideas or solutions.

推荐答案

我发现在 iOS 8 中,UIScrollView 的底层 UIPanGestureRecognizer 不尊重 UIScrollView 的 delaysContentTouches 属性.我认为这是一个 iOS 8 错误.这是我的解决方法:

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

这篇关于ios 8 - 水平滚动视图中的按钮拦截平移事件 - 滚动不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

UIButtons at the bottom of UIScrollView not working(UIScrollView 底部的 UIButtons 不起作用)
scrollViewWillEndDragging:withVelocity:targetContentOffset: not working on the edges of a UISCrollView(scrollViewWillEndDragging:withVelocity:targetContentOffset: 不在 UISCrollView 的边缘工作)
ImageView Scaling when scrolling down(向下滚动时 ImageView 缩放)
Bounds automatically changes on UIScrollView with content insets(UIScrollView 上的边界自动更改,带有内容插图)
iOS5 UITapRecognizer for UIScrollView interfering with buttons. How to fix?(用于 UIScrollView 的 iOS5 UITapRecognizer 干扰按钮.怎么修?)
Handling scroll views with (custom, interactive) view controller presentation and dismissal(使用(自定义、交互式)视图控制器呈现和解除处理滚动视图)