Created
January 31, 2014 02:48
-
-
Save mattbischoff/8725806 to your computer and use it in GitHub Desktop.
Receive UIKeyCommands without a text view or text field as the first responder.
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
@implementation TMDashboardViewController | |
#pragma mark - UIResponder | |
- (BOOL)canBecomeFirstResponder { | |
return YES; | |
} | |
- (NSArray *)keyCommands { | |
static NSArray *keyCommands; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
UIKeyCommand *composeCommand = [UIKeyCommand keyCommandWithInput:@"c" modifierFlags:UIKeyModifierAlternate action:@selector(composeShortcut:)]; | |
keyCommands = @[composeCommand]; | |
}); | |
return keyCommands; | |
} | |
#pragma mark - TMDashboardViewController | |
- (void)composeShortcut:(UIKeyCommand *)command { | |
[self compose]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment