bir kullanıcı bir anahtar bastığında:
durumunda UITextField
- (BOOL)textField:(UITextField *)textField
shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)string {
// Do something here...
}
Durumunda UITextView yılında:
- (BOOL)textView:(UITextView *)textView
shouldChangeTextInRange:(NSRange)range
replacementText:(NSString *)text {
// Do something here...
}
Bu nedenle, klavyeyi kullanarak bastığınız her tuşa her seferinde bu yöntem denir.
NSNotificationCenter'ı da kullanabilirsiniz. Bunlardan herhangi birini ViewDidLoad yöntemine eklemelisiniz.
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
UITextField:
[notificationCenter addObserver:self
selector:@selector(textFieldText:)
name:UITextFieldTextDidChangeNotification
object:yourtextfield];
Sonra yöntemde textFieldText:
kodunuzu koyabilirsiniz:
- (void)textFieldText:(id)notification {
// Do something here...
}
UITextView
[notificationCenter addObserver:self
selector:@selector(textViewText:)
name:UITextViewTextDidChangeNotification
object:yourtextView];
Sonra yöntemde textViewText:
kodunuzu koyabilirsiniz:
- (void)textViewText:(id)notification {
// Do something here...
}
yardımcı olur Umut.
Bunun yerine size bir sorum var, klavye gösterilmiyorsa kullanıcı nasıl bir şey yazabilir? –
İyi cevap burada. http://stackoverflow.com/questions/5216245/how-to-handle-key-events-in-iphone – Dilip
Metin alanı kullanıyor musunuz? onay [Bu] [1] [1] : Doğru hatırlamak http://stackoverflow.com/questions/7010547/uitextfield-text-change-event –