【问题标题】:dismissModalViewControllerAnimated doesn't always work?dismissModalViewControllerAnimated 并不总是有效?
【发布时间】:2010-01-07 23:50:33
【问题描述】:

是什么阻止模态视图控制器被解除?我发现dismissModalViewControllerAnimated 并不总是有效?例如这不起作用:

SettingsViewController* settings = [[SettingsViewController alloc] init];
UINavigationController *settingsNav = [[UINavigationController alloc] initWithRootViewController:settings];
[navigationController presentModalViewController:settingsNav animated:YES];     
[navigationController dismissModalViewControllerAnimated:YES];

谢谢!

【问题讨论】:

    标签: iphone uiviewcontroller modal-dialog


    【解决方案1】:

    如果您尝试将太多导航动画过于靠近,它们通常不会起作用。尝试在延迟 0.75 秒后执行您的 dismissModalViewControllerAnimated:。

    【讨论】:

      【解决方案2】:
      SettingsViewController* settings = [[SettingsViewController alloc] init];
      UINavigationController *settingsNav = [[UINavigationController alloc] initWithRootViewController:settings];
      [navigationController presentModalViewController:settingsNav animated:YES]; 
      [settingsNav dismissModalViewControllerAnimated:YES];
      

      如果 SettingsViewController 是 UIViewController 则:

      SettingsViewController* settings = [[SettingsViewController alloc] init];
      [self presentModalViewController:settings animated:YES]; 
      [settings dismissModalViewControllerAnimated:YES];
      

      【讨论】:

        猜你喜欢
        • 2012-12-26
        • 1970-01-01
        • 1970-01-01
        • 2012-04-23
        • 2015-06-28
        • 2015-12-04
        • 2017-01-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多