• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

iOS 7自定义键盘UIView触摸事件在底行延迟

[复制链接]
菜鸟教程小白 发表于 2022-12-12 10:57:55 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

这是一个奇怪的..

我有一个 UIView xib 文件,如下所示:

enter image description here

我已将每个 UIButton touchDowntouchUpInside 事件连接到两个 IBAction 方法:

- (IBAction)touchUpInsideid)sender
{
    NSLog(@"touch up inside");
    if (((UIButton *)sender == _enter) | ((UIButton *)sender == _back)) {
        [(UIButton *)sender setBackgroundColor:_color2];
    }
    else {
        [(UIButton *)sender setBackgroundColor:_color1];
    }
}

- (IBAction)touchDownid)sender
{
    NSLog(@"touch down");
    [(UIButton *)sender setBackgroundColor:_color2];
}

除了最底部的 UIButton 行之外,一切正常,这是奇怪的部分:

touch down 事件被触发,但按钮必须按住 0.5 秒才能改变背景颜色,而其他按钮是瞬时的。

它只发生在 UIButton 的最底部一行,因为我尝试使用按钮 @back、0、@enter 切换按钮 7、8、9,如下所示:

It is always the bottom-most row of <code>UIButton</code>'s that show the touchDown delay

我在 Interface Builder 中检查了所有 UIButton 属性都是相同的,并且我已经尝试移动 UIButton 的对象顺序,如您所见图片的左侧,我已经没有想法了。基本上奇怪的是 UIControl 行为根据其在父 View 上的位置而有所不同...

更新:我使父 UIView 高度值足够大,以至于最后一行下方有 50 个空闲像素,并且 UIButton 现在可以正常工作。我现在能想到的唯一原因是 UITabBar 下面有 2 个 View Controller 级别。即使这样也没有意义。



Best Answer-推荐答案


The document说:

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/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap