Last active
August 29, 2015 13:56
-
-
Save brianpartridge/8939270 to your computer and use it in GitHub Desktop.
An example of how to add keyboard commands to Debug builds of an iOS app. From http://cocoa.tumblr.com/post/75111441462/supporting-keyboard-shortcuts-without-uitextview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DEBUG | |
- (BOOL)canBecomeFirstResponder { | |
return YES; | |
} | |
- (NSArray *)keyCommands { | |
static NSArray *keyCommands; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
keyCommands = @[[UIKeyCommand keyCommandWithInput:UIKeyInputEscape | |
modifierFlags:UIKeyModifierCommand | |
action:@selector(handleEscapeCommand:)]]; | |
}); | |
return keyCommands; | |
} | |
- (void)handleEscapeCommand:(UIKeyCommand *)keyCommand { | |
[[Session currentSession] disconnect]; | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment