UIButton 无法在 iPhone 屏幕的底部区域正确注册触摸 [英] UIButton fails to properly register touch in bottom region of iPhone screen

查看:10
本文介绍了UIButton 无法在 iPhone 屏幕的底部区域正确注册触摸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,其中包含许多不同的按钮,这些按钮以计算器的形式排列,例如方形/矩形格式.它实际上与默认的 iOS 计算器极为相似.大约有 6 行,每个按钮 4 列.

I have an app with many different buttons arranged in a calculator like, square / rectangular format. It is actually extremely similar to the default iOS calculator. There are approximately 6 rows with 4 columns each of buttons.

问题

我遇到的问题涉及底行中的按钮(大约是 iPhone 4 屏幕的底部 10 位).它们在按下时的行为不正常,因为按下时必须按住它们(大约不到一秒钟)才能注册按钮按下".这与标准的短抽头相反.

The problem I am having involves the buttons in the bottom row (approximately the bottom 10th of the screen on an iPhone 4). They do not behave normally when pressed in the sense that when pressed, they have to be pressed and held (for roughly just under a second) to register a "button press". This is opposed to the standard short tap.

除此底行之外,没有其他按钮以这种方式运行.

No other buttons besides this bottom row behave in this fashion.

此外,如果点击这些按钮的上边缘,它们的行为正常,一旦被触摸就会响应.这让我相信按钮本身不是问题,但我的视图布局存在一些问题.

Additionally, if these buttons are tapped on their upper edge, they behave normally, responding as soon as they are touched. This leads me to believe that the buttons themselves are not the problems but there is some problem with the layout of my views.

还应注意,此问题仅存在于物理设备上.在模拟器上,按钮表现正常.

上下文

包含这些按钮的视图不是应用的根视图控制器.相反,它被转换为原样(这里没什么特别的):

The view containing these buttons is not the root view controller of the app. Instead it is transitioned to as so (nothing fancy here):

[self presentViewController:navController animated:YES completion:nil];

self 是根视图控制器

Where self is the root view controller

我遇到问题的视图控制器包含在导航控制器中,并由您在上面看到的根视图控制器以模态方式呈现.

The view controller I am having problems with is contained within a navigation controller and is presented modally by the root view controller which you can see above.

到目前为止我已经尝试过什么

  • 开启和关闭自动布局:同样的问题

  • Turning auto layout on and off: same problem

重新排列视图的层次结构:我将有问题的按钮移到所有其他按钮的顶部和后面具有相同结果的视图:相同的问题

Rearranging hierarchy of views: I moved the problematic buttons on top of and behind all other views with the same result: same problem

多台设备(iPhone 4、4s、5):同样的问题(尽管按钮在 3.5 英寸和 4 英寸模拟器上都能正常响应)

Multiple devices (iPhone 4, 4s, 5): same problem (although buttons respond normally on both 3.5 inch and 4 inch simulators)

测试其他应用(当该区域的按钮在其他应用上按下时,它们的行为正常)

Testing other apps (when buttons in this region are pressed on other apps, they behave normally)

其他信息

  • 所有内容都在 Interface Builder 中针对有问题的视图控制器进行了布局
  • 所有的按钮都是标准设置的系统按钮,除了文字之外都完全一样.
  • 屏幕的所有元素(按钮、标签等)都是视图"的子视图
  • 按钮彼此齐平,重叠不应超过一到两个像素.
  • 有问题的按钮尺寸为:80 宽 X 44 高.
  • 有问题的按钮与屏幕底部齐平
  • 除了按钮之外,还有一个 UIImage 和几个标签,但这些标签位于屏幕顶部,不会以任何方式与任何按钮重叠.

推荐答案

这听起来像是按钮和 UIScreenEdgePanGestureRecognizer(或其他任何东西)之间的交互,它负责检测用户想要调出系统的控制中心.

This sounds like an interaction between the buttons and the UIScreenEdgePanGestureRecognizer (or whatever it is) that is responsible for detecting that the user wants to bring up the system's Control Center.

这里实际上有两个潜在问题:

There are actually two potential issues here:

  • 在针对您的应用的手势与针对系统的手势之间可能存在交互(即冲突).如果您有手势识别器,您可能必须使用委托方法在它们和系统的手势识别器之间进行调解.

  • There can be an interaction (i.e. conflict) between the possibility of a gesture directed at your app and a gesture directed at the system. If you have gesture recognizers, you might have to use delegate methods to mediate between them and the system's gesture recognizers.

有一个公认的错误,即在屏幕边缘附近(即在屏幕边缘手势识别器的区域"中)轻按可以工作,但它会导致按钮行为异常物理上,即看起来它好像被点击了,即使日志显示它已经被点击了(在这里查看我的答案:https://stackoverflow.com/a/22000692/341994).

There is a well-established bug where a tap near the screen edge (i.e. in the screen edge gesture recognizer's "zone") works but it causes the button to misbehave physically, i.e. it doesn't look as if it's been tapped even though logging shows that it has (see my answer here: https://stackoverflow.com/a/22000692/341994).

这篇关于UIButton 无法在 iPhone 屏幕的底部区域正确注册触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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