重点关注UIButton时,Siri Remote的菜单按钮未退出应用程序 [英] Siri Remote's Menu Button not exiting application when UIButton is focused
本文介绍了重点关注UIButton时,Siri Remote的菜单按钮未退出应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要覆盖pressesBegan
以接收Select印刷机.当焦点位于UIButton
上时,Siri Remote的菜单按钮不会退出我的应用程序.如果没有将UI元素作为焦点,则菜单按钮将按预期工作.
I'm overriding pressesBegan
to receive Select presses. The Siri Remote's Menu Button does not exit my application when the focus is on a UIButton
. If no UI element is focused the Menu Button works as expected.
当焦点位于UIButton
上时如何接收菜单按钮按下?
How do I receive Menu Button presses when the focus is on a UIButton
?
override func pressesBegan(presses: Set<UIPress>, withEvent event: UIPressesEvent?) {
for item in presses {
if item.type == .Select {
print("Click")
}
if item.type == .Menu {
print("Menu Button")
super.pressesBegan(presses, withEvent: event)
}
}
}
推荐答案
UIButton
仅响应遥控器上的.Select
按钮.您可以使用点击手势识别器来捕捉菜单按钮.例如:
UIButton
only responds to the .Select
button on the remote. You can catch the menu button using a tap gesture recognizer. For example:
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(ClassName.menuPressed()))
tapRecognizer.allowedPressTypes = [NSNumber(integer: UIPressType.Menu.rawValue)];
view.addGestureRecognizer(tapRecognizer)
然后执行:
func menuPressed() {
// do something
}
这篇关于重点关注UIButton时,Siri Remote的菜单按钮未退出应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文