5

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

bolav
  • 6,938
  • 2
  • 18
  • 42
Devhess
  • 289
  • 4
  • 16

1 Answers1

0

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.

Christian A. Strømmen
  • 3,181
  • 2
  • 25
  • 46