UIKeyCommand自定义键盘

来源:互联网 发布:免费下载源码的网站 编辑:程序博客网 时间:2024/06/10 02:11

有时候给自己的程序添加一些自定义的快捷键也是有必要的,在需要添加快捷键的viewController里面添加

-(BOOL)canBecomeFirstResponder{

    return YES;

}


-(NSArray *)keyCommands{

//组合键

    return@[[UIKeyCommandkeyCommandWithInput:UIKeyInputEscapemodifierFlags:UIKeyModifierShiftaction:@selector(escapeShiftKeyPressed:)]];

}


-(void)escapeShiftKeyPressed:(UIKeyCommand *)keyCommand{

    UIAlertView *alertView = [[UIAlertViewalloc] initWithTitle:@"UIKeyCommand Demo"message:[NSStringstringWithFormat:@"%@ pressed", keyCommand.input]delegate:nilcancelButtonTitle:@"Ok"otherButtonTitles:nil];

    [alertViewshow];

}



0 0
原创粉丝点击