使用 IOS9 时,无法在 UITable 的部分标题上的 UIButtons 上触发触摸事件(IOS10 很好) [英] Unable to get touch events to fire on UIButtons on section headers of UITable when using IOS9 (IOS10 is fine)

查看:25
本文介绍了使用 IOS9 时,无法在 UITable 的部分标题上的 UIButtons 上触发触摸事件(IOS10 很好)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 IOS 9 上,触摸表部分标题上的按钮不起作用,但在 IOS 10 上工作正常.这是使用 swift 3 和 XCode 8 和 9.我已经用物理设备和模拟器进行了测试,始终使用同样的结果.我的按钮位于 StackView 内、StackView 内、内容视图内、用户标题内.我发现部分页脚上的 UIButton 没有问题,但这不是我想使用它们的地方.当我在 IOS10 设备或模拟器上测试时一切正常,但从未在 IOS9 设备上测试.

On IOS 9, touching buttons on table section header does not work, but works fine on IOS 10. This is using swift 3 both with XCode 8 and 9. I've tested with physical devices and the Simulator, always with the same result. My buttons are within a StackView, within a StackView, within the Content View, within userheader. I've found no problems with a UIButton on the section footer, but that's not where I want to use them. Everything works fine when I test on a IOS10 device or Simulator, but never on an IOS9 one.

奇怪的是,这似乎类似于另一个问题 在 stackoverflow 上报告了它适用于 IOS9 但不适用于 IOS10

Strangely, this seems similar to another problem reported on stackoverflow where it works for IOS9 but not for IOS10

推荐答案

我无法从这个描述中看出问题所在,但可以尝试一下.

I can't tell the problem from this description, but here's something to try.

在 Xcode 中运行应用程序,然后选择 Xcode>Debug>View Debugging>Capture View Hierarchy 菜单项.检查 StackView、按钮等的视图,并确保按照您的预期布局,没有遮挡可点击区域,并且视图大小和位置正确.

Run the app in Xcode, then select the Xcode>Debug>View Debugging>Capture View Hierarchy menu item. Examine the views of the StackView, buttons, etc. and make sure things are laid out as you expect with nothing obscuring the tappable areas and the view sizes and positions correct.

如果按钮位于具有不正确大小(如零宽度)的视图中,或者位于将它们置于超级视图边界之外的偏移量处,则点击将不起作用.但是,除非将包含视图设置为裁剪到边界,否则您不会注意到.否则,整个按钮将被绘制并看起来可点击.

If the buttons are in a view that has an incorrect size like a zero width, or are at an offset that puts them outside the bounds of the superview, taps won't work. But, you won't notice that unless containing views are set to clip to bounds. Otherwise, the entire button will draw and look tappable.

我不能肯定地说就是这样,但是对于这些类型的问题,一个可能的嫌疑人是重叠视图窃取了触摸或触摸被超级视图剪掉了.

I can't say that this is it for sure, but with these types of issues, a likely suspect is an overlapping view stealing the touches or the touches being clipped by a superview.

这篇关于使用 IOS9 时,无法在 UITable 的部分标题上的 UIButtons 上触发触摸事件(IOS10 很好)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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