这是一个奇怪的..
我有一个 UIView
xib 文件,看起来像这样:
我已将每个 UIButton
touchDown
和 touchUpInside
事件连接到两个 IBAction
方法:
- (IBAction)touchUpInside:(id)sender
{
NSLog(@"touch up inside");
if (((UIButton *)sender == _enter) | ((UIButton *)sender == _back)) {
[(UIButton *)sender setBackgroundColor:_color2];
}
else {
[(UIButton *)sender setBackgroundColor:_color1];
}
}
- (IBAction)touchDown:(id)sender
{
NSLog(@"touch down");
[(UIButton *)sender setBackgroundColor:_color2];
}
除了 UIButton
的最底行外,一切正常,这是奇怪的部分:
触发了 touch down
事件,但必须按住按钮 0.5 秒才能更改背景颜色,而其他按钮则为瞬时。
它只发生在 UIButton
的最底行,因为我尝试用按钮 @back、0、@enter 切换按钮 7、8、9,如下所示:
我已经在 Interface Builder 中检查了所有 UIButton
属性是否相同,并且我已经尝试移动 UIButton
的对象顺序,如您所见图片的左侧,我已经没有想法了。基本上奇怪的是 UIControl
行为根据其在父 View 中的位置而有所不同...
更新:我将父 UIView
高度值设置得足够大,最后一行下方有 50 个空闲像素,UIButton
现在工作正常。我现在能想到的唯一原因是下面有一个 UITabBar
2 个 View Controller 级别。即便如此也没有意义。
最佳答案
Expect users to swipe up from the bottom of the screen to reveal Control Center. If iOS determines that a touch that begins at the bottom of the screen should reveal Control Center, it doesn’t deliver the gesture to the currently running app. If iOS determines that the touch should not reveal Control Center, the touch may be slightly delayed before it reaches the app.
这里有一个解决方案: UIButton fails to properly register touch in bottom region of iPhone screen
但是,在您的情况下,我认为您应该在 UIResponder
中使用 inputView
。
请参阅:https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/InputViews/InputViews.html
inputView
不受该问题的影响。
关于iOS 7 自定义键盘 UIView 触地事件在底行延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25052832/