我有一个带按钮的模式视图,单击后添加一个全屏视图控制器。在ios 4.3 sdk中,我被要求退出时已关闭(并使用push / pop控制器方法,并使用present / dismiss modalViews)。在新的ios 5 sdk中,它无法退出,viewController的parentViewController为nil并且卡住了。
有什么建议么?

添加代码:

 myTypeController* vc = [[myTypeController alloc] initWithSomeData:myData];
 vc.hidesBottomBarWhenPushed = YES
//This way
//[self.parentViewController presentModalViewController:vc animated:NO];
//Or that
 [self.parentViewController.navigationController pushViewController:vc animated:YES];
 [vc release];

和通常的删除方式
 [self.parentViewController dismissModalViewControllerAnimated:YES];

要么
[self.navigationController popViewControllerAnimated:YES];

最佳答案

iOS 5要求您使用presentingViewController:

if ([currentView parentViewController] != nil)
{
    // iOS 4
    self.isDismissingView = YES;
    [[currentView parentViewController] dismissModalViewControllerAnimated:animated];
}
else if ([currentView presentingViewController] != nil)
{
    // iOS5
    self.isDismissingView = YES;
    [[currentView presentingViewController] dismissModalViewControllerAnimated:animated];
}

此处更多信息:http://omegadelta.net/2011/11/04/oh-my-god-they-killed-parentviewcontroller/

10-07 21:24