我正在使用UIPickerView,我希望我的鍵盤永遠不會顯示我的一些UITextFields。當我在UITextField上觸摸它後調用resignFirstResponder時,它不會使鍵盤停下來。UITextField always resignFirstResponder
- (IBAction) txtFieldClicked:(id)sender {
[txtField resignFirstResponder];
}
我正在使用UIPickerView,我希望我的鍵盤永遠不會顯示我的一些UITextFields。當我在UITextField上觸摸它後調用resignFirstResponder時,它不會使鍵盤停下來。UITextField always resignFirstResponder
- (IBAction) txtFieldClicked:(id)sender {
[txtField resignFirstResponder];
}
設置文本字段代表和執行其委託的方法
如果你不想在鍵盤彈出,所有在這裏
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
if([textField isEqualTo:self.myTextField]) {
return NO;
}
return YES;
}
謝謝pratikshabhisikar。我讚賞另一個快速和正確的答案。 – Jackelope11 2011-06-02 18:09:44
對於每個文本字段,你不希望能夠以顯示鍵盤,這樣做:
[textField setUserInteractionEnabled:NO];
您還可以檢查在界面生成器的用戶界面中的對應塊。這可以防止文本字段接收觸摸事件,否則會觸發它顯示鍵盤。
它變成了我們,我只需要成爲第一響應者,而不是辭職,但你的代碼也可以工作。 – Jackelope11 2011-06-02 18:02:49
發佈您的代碼的文本字段返回NO 。 – Saphrosit 2011-06-02 17:56:34