Daniel Storm Daniel Storm - 8 months ago 56
Swift Question

Siri Remote's Menu Button not exiting application when UIButton is focused

I'm overriding

to receive Select events. The Siri Remote's Menu Button does not exit my application when the focus is on a
. If no UI element is focused the Menu Button works as expected.

How do I receive Menu Button presses when the focus is on a

override func pressesBegan(presses: Set<UIPress>, withEvent event: UIPressesEvent?) {
for item in presses {
if item.type == .Select {
if item.type == .Menu {
print("Menu Button")
super.pressesBegan(presses, withEvent: event)


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)];

Then implement:

func menuPressed() {
    // do something