[英]Delay of button's highlighted state
I have the issue in two completely different situations, which makes it really weird. 我在两个完全不同的情况下遇到了这个问题,这让人很奇怪。
In both situations the buttons's are only highlighted after a slight delay, approximately .5 - 1 second. 在这两种情况下,按钮仅在稍微延迟后突出显示,约为0.5-1秒。 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). 它们都可以在模拟器上完美运行,但不能在真实设备上运行(我有一个带有iOS 7.0.4的iPhone 5s)。
What I tried 我尝试了什么
Setting the zPosition to the highest value (MAXFLOAT) of these views, to ensure nothing is blocking the tap. 将zPosition设置为这些视图的最高值(MAXFLOAT),以确保没有任何东西阻止点击。
Explicitly enabling the highlighting. 明确启用突出显示。
Both obviously doesn't worked. 两者显然都没有用。
Edit: Still not solved. 编辑:仍未解决。
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). 系统边缘手势与控制中心(或iPhone X和iPad上的App Switcher)存在冲突。 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. 但请注意,这将要求用户滑动两次以激活系统手势。
I know it's been a long time, but I just faced a similar issue: 我知道这已经很久了,但我刚遇到了类似的问题:
UIButton
is a subview of UINavigationController.view
我的UIButton
是UINavigationController.view
的子视图 I just found out that it only happens if I run the app from Xcode. 我发现只有从Xcode运行应用程序才会发生这种情况。 If I disconnect the device and open the app from it's icon everything works just fine. 如果我断开设备并从它的图标打开应用程序一切正常。
I hope it helps. 我希望它有所帮助。
Are the UIButtons inside a UIScrollView ? UIBcroll在UIScrollView中吗? If they are, the delay is there so the scrollview can determine whether the touch is for scrolling or it should be passed on to the subview. 如果是,则延迟在那里,因此滚动视图可以确定触摸是用于滚动还是应该传递到子视图。
See also UIButton touch is delayed when in UIScrollView 另请参见UIScrollView中的UIButton触摸延迟
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.