Try iPad Shortcuts in Simulator

446 views Asked by At

With iOS 9 Developers can add Shortcuts to an iPad App using UIKeyCommand. Those are typed on an external keyboard and a function reacts.

Is there a way to test those in the simulator on the mac? Or show them like here:

enter image description here

1

There are 1 answers

0
Christian A. Strømmen On

After setting the keyboard shortcuts for your UIResponder subclass (keyCommands variable) you need to make your object first responder. I do it like this:

override func viewDidAppear(_ animated: Bool) {
    becomeFirstResponder()
}

override var canBecomeFirstResponder: Bool {
    return true
}

Holding down command on your keyboard should now pop up the shortcut-view.