1
對於我的iPad應用程序,當按下按鈕時,我有一個模態地顯示爲表單的視圖。爲了讓鍵盤在文本框中輸入文字後解散,我按照建議嘗試了;如何在使用modalPresentationStyle時關閉iPad上的鍵盤
「disablesAutomaticKeyboardDismissal」方法。
這不起作用,實際上,該方法從來沒有被稱爲根據日誌。 鑰匙將解僱iPhone或當我選擇不呈現模態。
這裏是我的代碼:
- (BOOL)disablesAutomaticKeyboardDismissal
{
NSLog(@"method calls");
return NO;
}
- (IBAction)showNewView:(id)sender
{
MyViewController *mvc =
[[MyViewController alloc] init];
// some lines about setting content
//...
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:mvc];
[navController setModalPresentationStyle:UIModalPresentationFormSheet];
[self presentViewController:navController animated:YES completion:nil];
}
- (BOOL)disablesAutomaticKeyboardDismissal 與否,鍵盤沒有被駁回,除非我刪除TIS線:
// [navController setModalPresentationStyle:UIModalPresentationFormSheet];
但是,那麼它是沒有呈現我想要的方式了。
任何人都可以看到我做錯了什麼?
技術上一個是不應該繼承UINavigationController的,但我我自己有這個問題,找不到替代解決方案。 – isaac
如果使用UINavigationController顯示模態,請小心。然後,您必須在導航控制器上設置不可用的自動鍵盤釋放,而不是在視圖控制器上。 – thatzprem