如果模态ViewController演示文稿样式是UIModalPresentationFormSheet,则iPad键盘不会被忽略 [英] iPad keyboard will not dismiss if modal ViewController presentation style is UIModalPresentationFormSheet

查看:237
本文介绍了如果模态ViewController演示文稿样式是UIModalPresentationFormSheet,则iPad键盘不会被忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:

从iOS 4.3开始,请参阅已接受的答案(不是最受欢迎的答案)。

See accepted answer (not top voted one) for solution as of iOS 4.3.

问题是关于在iPad键盘中发现的行为,如果在带有导航控制器的模态对话框中显示,则拒绝解除该行为。

This question is about a behavior discovered in the iPad keyboard, where it refuses to be dismissed if shown in a modal dialog with a navigation controller.

基本上,如果我使用以下行显示导航控制器,如下所示:

Basically, if I present the navigation controller with the following line as below:

navigationController.modalPresentationStyle = UIModalPresentationFormSheet;

键盘拒绝被解雇。如果我注释掉这一行,键盘就会消失。

The keyboard refuses to be dismissed. If I comment out this line, the keyboard goes away fine.

...

我有两个textFields,用户名和密码; username有一个Next按钮,密码有一个Done按钮。如果我在模态导航控制器中显示它,键盘将不会消失。

I've got two textFields, username and password; username has a Next button and password has a Done button. The keyboard won't go away if I present this in a modal navigation controller.

工作

broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil];
[self.view addSubview:b.view];

不工作

broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil];
UINavigationController *navigationController = 
[[UINavigationController alloc]
 initWithRootViewController:b];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
navigationController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
[b release];

如果我删除导航控制器部件并将'b'作为模态视图控制器单独显示,作品。导航控制器是问题吗?

If I remove the navigation controller part and present 'b' as a modal view controller by itself, it works. Is the navigation controller the problem?

工作

broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil];
b.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:b animated:YES];
[b release];

WORKS

broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil];
UINavigationController *navigationController = 
    [[UINavigationController alloc]
         initWithRootViewController:b];
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
[b release];


推荐答案

在以模态方式呈现的viewController中,只需覆盖disablesAutomaticKeyboardDismissal to总是返回NO

In the viewController that is presented modally just overwrite disablesAutomaticKeyboardDismissal to always return NO

- (BOOL)disablesAutomaticKeyboardDismissal {
    return NO;
}

这篇关于如果模态ViewController演示文稿样式是UIModalPresentationFormSheet,则iPad键盘不会被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆