【问题标题】: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];