這可能不是iOS 4.x中的一個錯誤。即使在iOS 9.x中,這種情況依然存在。
對於日本/中國或可以選擇從鍵盤上面的字的建議列表中的單詞任何其他語言,此委託方法
- (BOOL) textField : (UITextField *) textField shouldChangeCharactersInRange : (NSRange) range replacementString : (NSString *) string
不會也是UITextField的called.The文本由選用附加詞直。
一種解決方法是使用UITextFieldTextDidChangeNotification
:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(checkForTextfield:)
name:UITextFieldTextDidChangeNotification
object:nil];
受影響的文本字段存儲在通知的對象參數。 userInfo字典未使用。
- (void)checkForTextfield:(NSNotification *)noti{
UITextField* textField = noti.object;
//do whatever you want with the UITextfield
}
而且不要忘了當的dealloc從NSNotificationCenter
刪除自身:
- (void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
這聽起來像iOS版的一個bug。你使用的是哪個版本的iOS?如果你正在輸入英文,這個委託會被調用嗎? – xuzhe
我發現這個模擬器很可能是4.3。這個代表在英文時被調用。當你從建議列表中選擇單詞時,它不會被調用,就像在iPad中一樣。 – rae148