禁用外接键盘的键盘快捷键

时间:2011-04-18 11:22:05

标签: objective-c cocoa-touch ipad keyboard-shortcuts

我正在尝试在iPad上使用UITextview创建一个简单的编辑器。在我使用外部键盘在设备上试用我的应用程序之前,一切都很顺利。有些键盘快捷键会干扰我的应用:命令 + 删除选项 + 删除等。

我想我不需要这些快捷方式,所以我想禁用它们。我能这样做吗?有人可以告诉我该怎么做吗?

1 个答案:

答案 0 :(得分:1)

使用UItTouch事件

在触摸文本字段以外的任何位置时禁用键盘
- (void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event {  
    if (myTextField) {  
        if ([myTextField canResignFirstResponder]) [myTextField resignFirstResponder];  
    }  
    [super touchesBegan: touches withEvent: event];  
} 

有关详细信息,请访问我的博客:

http://aruntheiphonedeveloper.blogspot.com/2011/05/disabing-keyboard-using-uitouch-event.html

相关问题