[英]iOS : How to detect any key pressed when use a BT keyboard
I have to implement a manufacturer keyboard test app of iOS on iPad. 我必须在iPad上实现iOS的制造商键盘测试应用程序。
I am surveying on this topic right now. 我正在调查这个话题。
According to this article 根据这篇文章
[_myUITextField becomeFirstResponder];
[_myUITextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventAllEvents];
}
-(IBAction)textFieldDidChange:(id)sender{
UITextField *_field = (UITextField *)sender;
NSLog(@"%@",[_field text]);
}
With these code I can detect the letter(like 1,2,3,a,b,c...) I pressed in my app, but not all key pressed (like fn, ctl, cmd ...etc?) 使用这些代码,我可以检测到我在我的应用程序中按下的字母(如1,2,3,a,b,c ......),但不是所有键都按下了(如fn,ctl,cmd ......等?)
Anyone know how to achieve this...thanks^^ 任何人都知道如何实现这一点...谢谢^^
Try Notification center instead. 请尝试通知中心。
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
UITextField : UITextField:
[notificationCenter addObserver:self
selector:@selector (textFieldText:)
name:UITextFieldTextDidChangeNotification
object:yourtextfield];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.