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

查看:72
本文介绍了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中为有问题的视图构建troller

  • 所有按钮都是标准设置的系统按钮,除了文本外,它们都完全相同。

  • 屏幕的所有元素(按钮,标签等)是视图的子视图。

  • 按钮彼此齐平,不应重叠超过一个或两个像素。

  • 有问题的按钮有尺寸:80宽X 44高。

  • 有问题的按钮与屏幕底部齐平

  • 除了按钮之外,还有一个UIImage和几个标签,但它们位于屏幕的顶部,不会以任何方式与任何按钮重叠。

  • Everything is laid out in Interface Builder for the problematic view controller
  • All of the buttons are system buttons with standard settings and are all exactly the same besides their text.
  • All of the elements of the screen (buttons, labels, etc. ) are subviews of the "view"
  • The buttons are flush against each other and should not overlap more than one or two pixels.
  • The problematic buttons have dimensions: 80 width X 44 height.
  • The problematic buttons are flush against the bottom of the screen
  • In addition to the buttons, there is one UIImage and several labels however these are at the top of the screen and do not overlap with any of the buttons in any way.

推荐答案

这听起来像按钮和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 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.

有一个完善的错误,其中a点击屏幕边缘附近(即在屏幕边缘手势识别器的区域)工作,但它会导致按钮物理行为错误,即它不会看起来就好像它是即使记录显示它已经被窃听(请参阅我的答案: 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天全站免登陆