2012-11-06 53 views
2

我試圖隱藏具有FormSheet樣式的模式視圖上的iPad鍵盤。我試圖辭去FirstResponder,但沒有任何反應。這是一個錯誤還是根本不工作?隱藏iPad中的ModalView(FormSheet)中的鍵盤

問候

編輯

-(void)hideKeyboards 
{ 
[emailField resignFirstResponder]; 
[passwordField resignFirstResponder]; 
[confirmPasswordField resignFirstResponder]; 
} 

-(IBAction)emailFieldDone:(id)sender 
{ 
[self hideKeyboards]; 
} 

-(IBAction)passwordFieldDone:(id)sender 
{ 
[self hideKeyboards]; 
} 

-(IBAction)confirmPasswordFieldDone:(id)sender 
{ 
[self hideKeyboards]; 
} 
+0

你有沒有在.h文件中設置委託? – kb920

+0

這就是我所嘗試的: - (void)hideKeyboards {0FireField resignFirstResponder]; [passwordField resignFirstResponder]; [confirmPasswordField resignFirstResponder]; } - (IBAction)emailFieldDone:(id)sender {[self hideKeyboards]; }(IBAction)passwordFieldDone:(id)sender {[self hideKeyboards]; }(IBAction)confirmPasswordFieldDone:(id)sender {[self hideKeyboards]; } –

+0

檢查你是否將委託設置爲xib中的文本字段或設置textfield.delegate = self; –

回答

3

重寫disablesAutomaticKeyboardDismissal返回NO如下固定我的同樣的問題。您需要覆蓋UINavigationControllerdisablesAutomaticKeyboardDismissal而不是自己的視圖控制器來解決此問題。也許用一類是一個好主意:

- (BOOL)disablesAutomaticKeyboardDismissal { 
    return NO; 
} 

另外,如果你想獲得一個詳細的解釋檢查這個iPad keyboard will not dismiss if modal view controller presentation style is UIModalPresentationFormSheet問題。

+0

嗨,我試過,但它沒有工作.. –

+0

你需要重寫UINavigationController disablesAutomaticKeyboardDismissal,而不是自己的視圖控制器。 – sunkehappy

+0

哦謝謝,我會試試這個。 –

0

設置委派到所有文本字段

textField.delegate=self; 
+0

我已經這樣做了...不起作用,但謝謝! –

2

試試這個,如果你正在使用的TextView

Textviewobjectname.editable = NO;