如果iPad的ModalSheet是ModalPresentation,则将不显示ModalSheet键盘样式

  • 问题:
  • 注意:

    关于iOS4.3版的解决方案,请参阅接受的答案(不是最热门的答案)

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

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

    navigationController.modalPresentationStyle = UIModalPresentationFormSheet;

    这个键盘拒绝被解除。如果我把这一行注释掉,键盘就没问题了。在

    我有两个文本字段,username和password;username有一个Next按钮,password有一个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];

  • 答案:
  • 在以模块方式呈现的视图控制器中,只需重写disablesAutomaticyboardDismissal返回NO

    - (BOOL)disablesAutomaticKeyboardDismissal {
    return NO;
    }