このソリューションは iPhoneのキーボードイベントを受信します
通知センターを使用してキープレスイベントをキャプチャする方法を提供します。
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyPressed:) name: UITextFieldTextDidChangeNotification object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyPressed:) name: UITextViewTextDidChangeNotification object: nil];
........
-(void) keyPressed: (NSNotification*) notification
{
NSLog([[notification object]text]);
}
正常に動作しますが、キーボードから押されたすべてのキーに対して、keyPressed関数が3回呼び出されます。
これは正常ですか、それとも私は何か間違ったことをしていますか?
テオ