dismissModalViewControllerAnimated并不总是有效?

时间:2010-01-07 23:50:34

标签: iphone uiviewcontroller modal-dialog

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

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

谢谢!

2 个答案:

答案 0 :(得分:5)

如果您尝试将太多导航动画放得太近,它们通常无法正常工作。尝试执行你的dismissModalViewControllerAnimated:延迟0.75秒后。

答案 1 :(得分:1)

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];