iOS 7的问题并滚动浏览包含UIButtons的UIScrollView [英] Issues with iOS 7 and scrolling through a UIScrollView that contains UIButtons

查看:86
本文介绍了iOS 7的问题并滚动浏览包含UIButtons的UIScrollView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务是更新我没有写的应用程序。它包含一个水平滚动的滚动视图,只包含UIButtons。按钮不仅具有打开它们所代表的应用程序的操作,而且如果轻敲并保持它们,则可以拖动它们。有问题的滚动视图下面还有另一个滚动视图,它接受拖动按钮。

I've been tasked with updating an app we have that I didn't write. It contains a scrollview that scrolls horizontally and only contains UIButtons. The buttons not only have an action to open the app they represent, but they can be dragged if tapped and held. There is another scrollview below the scrollview in question that accepts the dragging of the buttons.

在iOS 7之前,一切都已按预期工作。在iOS 7设备上,触摸滚动视图后立即注册按钮点击。该按钮将显示一个点亮的状态,就像它被选中一样,滚动视图将开始滚动。在iOS 7之前的设备上,滚动视图将开始滚动而不是注册水龙头。

Everything has and is working as expected pre iOS 7. On an iOS 7 device, the button taps are being registered as soon as the scrollview is touched. The button will show a lit state like it was selected and the scrollview will begin scrolling. On a pre iOS 7 device, the scrollview will begin to scroll instead of registering the tap.

任何人都遇到UIScrollView与iOS7的任何问题? setDelaysContentTouches:设置为YES,这可以防止这种情况发生。我很茫然。

Anyone experience any issues with UIScrollView with iOS7? setDelaysContentTouches: is set to YES, which should prevent this from happening. I'm at a loss.

推荐答案

其中一个重大问题是按钮也可以拖动。它们可以在自己的滚动视图中拖动并重新排序,或者移动到另一个滚动视图。我们最终做的是子类化滚动视图中使用的按钮。子类跟踪原始按钮所有者是谁并覆盖 touchesBegan: touchesMoved: touchesCancelled:

One of the big problem issues was that the buttons could also be draggable. They could be dragged around and reordered in their own scrollview, or moved to another scrollview. What we ended up doing was subclassing our buttons being used in the scrollviews. The subclass kept track of who the original button owner was and overrode touchesBegan: , touchesMoved: , and touchesCancelled:.

当我们的按钮子类识别出触摸时,它将确定是否正在拖动按钮并调用适当的方法。然后我们首先在我们的触摸方法上调用super,然后在 [self nextResponder] 上调用super。

When touches were recognized by our button subclass, it would determine if the button was being dragged and call the appropriate method. We then would call super on our touch methods first, and then on [self nextResponder].

这是公司代码,所以我不能直接发帖而不问。如果我没问题,我会用实际代码更新我的答案。

It is company code, so I can't directly post it without asking. If I get the okay, I'll update my answer with the actual code.

这篇关于iOS 7的问题并滚动浏览包含UIButtons的UIScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆