如果模态ViewController演示文稿样式为UIModalPresentationFormSheet,则iPad键盘不会被忽略注意:从iOS 4.3开始,请参阅已接受的答案(不是最受欢迎的答案)。这个问题是关于在iPad键盘中发现的行为,如果在带有导航控制器的模态对话框中显示,它将拒绝被解雇。基本上,如果我使用以下行显示导航控制器,如下所示:navigationController.modalPresentationStyle = UIModalPresentationFormSheet;键盘拒绝被解雇。如果我注释掉这一行,键盘就会消失。...我有两个textFields,用户名和密码; username有一个Next按钮,密码有一个Done按钮。如果我在模态导航控制器中显示它,键盘将不会消失。作品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”作为模态视图控制器单独显示,则可以正常工作。导航控制器是问题吗?作品broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil];b.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;[self presentModalViewController:b animated:YES];[b release];作品broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil];UINavigationController *navigationController =
[[UINavigationController alloc]
initWithRootViewController:b];[self presentModalViewController:navigationController animated:YES];[navigationController release];[b release];
3 回答
沧海一幻觉
TA贡献1824条经验 获得超5个赞
在以模态方式呈现的视图控制器中,只需覆盖disablesAutomaticKeyboardDismissal
以返回NO
:
- (BOOL)disablesAutomaticKeyboardDismissal { return NO;}
暮色呼如
TA贡献1853条经验 获得超9个赞
如果要显示带有的模态,请小心UINavigationController
。然后,您必须disablesAutomaticKeyboardDismissal
在导航控制器上设置,而不是在视图控制器上。您可以使用类别轻松完成此操作。
文件:UINavigationController + KeyboardDismiss.h
#import <Foundation/Foundation.h>@interface UINavigationController (KeyboardDismiss)- (BOOL)disablesAutomaticKeyboardDismissal;@end
文件:UINavigationController + KeyboardDismiss.m
#import "UINavigationController+KeyboardDismiss.h"@implementation UINavigationController(KeyboardDismiss)- (BOOL)disablesAutomaticKeyboardDismissal{ return NO;}@end
不要忘记在使用UINavigationController的文件中导入类别。
- 3 回答
- 0 关注
- 614 浏览
添加回答
举报
0/150
提交
取消