按钮突出显示状态的延迟 [英] Delay of button's highlighted state

查看:247
本文介绍了按钮突出显示状态的延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在两个完全不同的情况下,我遇到了这个问题,这真使我很奇怪.

I have the issue in two completely different situations, which makes it really weird.

  1. 情况:一个UIButton,作为另一个UIView的子视图.
  2. 情况:UIToolBar中的UIBarButtonItem.

在两种情况下,按钮的显示仅在稍微延迟大约5-1秒后才突出显示.正常点击时,一定要长以突出显示视图.它们都可以在模拟器上完美运行,但不能在真实设备上运行(我有配备iOS 7.0.4的iPhone 5s).

In both situations the buttons's are only highlighted after a slight delay, approximately .5 - 1 second. Definitely to long to highlight the view when tapping it normally. They both work perfectly on the simulator, but not on a real device (I have an iPhone 5s with iOS 7.0.4).

我尝试过的事情
将zPosition设置为这些视图的最大值(MAXFLOAT),以确保没有任何东西阻塞水龙头.
明确启用突出显示.

What I tried
Setting the zPosition to the highest value (MAXFLOAT) of these views, to ensure nothing is blocking the tap.
Explicitly enabling the highlighting.

显然两者都不起作用.

仍未解决.

推荐答案

如果将按钮放置在靠近显示屏底部的位置,则会发生这种情况.呈现Control Center(或iPhone X和iPad上的App Switcher)与系统边缘手势存在冲突.它将延迟您对按钮的触摸,直到确定用户没有执行系统手势为止.

This can happen if the buttons are placed close to the bottom edge of the display. There's a conflict with the system edge gesture to present Control Center (or App Switcher on iPhone X and iPad). It delays touches for your buttons until it's determined the user isn't performing a system gesture.

如果愿意,可以告诉系统将手势优先于系统手势.

If you would like, you can tell the system to give precedence to your gestures over the system gestures.

override func preferredScreenEdgesDeferringSystemGestures() -> UIRectEdge {
    return .bottom
}

但是请注意,这将要求用户滑动两次以激活系统手势.

Do note however that this will require the user swipe twice to activate the system gesture.

这篇关于按钮突出显示状态的延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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