有时候给自己的程序添加一些自定义的快捷键也是有必要的,在需要添加快捷键的viewController里面添加
-(BOOL)canBecomeFirstResponder{
return YES;
}
-(NSArray *)keyCommands{
//组合键
return @[[UIKeyCommand keyCommandWithInput:UIKeyInputEscape modifierFlags:UIKeyModifierShift action:@selector(escapeShiftKeyPressed:)]];
}
-(void)escapeShiftKeyPressed:(UIKeyCommand *)keyCommand{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"UIKeyCommand Demo" message:[NSString stringWithFormat:@"%@ pressed", keyCommand.input] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alertView show];
}