dismissModalViewControllerAnimated不起作用
我有一个UITabbarController与UINavigationController。 NavigationController中的视图呈现一个MVC(AddClockNavigationController)。 这个MVC有一个带有视图的笔尖和一个UINavigationController。 NavigationController.view作为子视图添加到MVC的视图中。
我的MVC中的NavigationController有两个button,一个取消和一个完成。 当按其中任何一个MVC应该被解雇。 这些button的IBActions在UINavigationController的视图(AddClockViewController)中,但是每当按下它们时,MVC都不会消失。 如果我把这些动作放到MVC中,它确实会消失。 如果我把这个函数放在我的MVC中,并使用[self.parentViewController myFunction]从我的viewController调用它,它不会消失。
我怎样才能让它从我的视野中消失?
我想我的ex is很乱,但我希望你能理解。
我的IB观点:
最好的祝福,
保罗·佩伦
编辑我已经尝试过[self dismissModalViewControllerAnimated:YES];
, [self.parentViewController dismissModalViewControllerAnimated:YES];
, [self.navigationController dismissModalViewControllerAnimated:YES];
, [self.parentViewController.navigationController dismissModalViewControllerAnimated:YES];
如前所述,在父视图中使用一个函数来解除它。 没有任何工作
当某个视图控制器呈现另一个时,它将成为父视图控制器。 所以,如果你想解雇你的模式视图控制器,那么你必须select:
-
从父视图控制器调用
[self dismissModalViewControllerAnimated:YES];
要么
-
从模态视图控制器调用
[self.parentViewController dismissModalViewControllerAnimated:YES];
你其实不需要导航控制器(因为你不推/弹任何视图控制器)。 只需将UINavigationBar添加到您的MVC并在其上放置button。 然后添加行动给他们,做select#2。 你的代码不工作,因为导航控制器没有父母,因为它没有被呈现为模态。
一种情况是,在调用viewController的viewDidAppear之前调用dismiss {Modal} ViewControllerAnimated。 在这种情况下,呈现的是animation== YES。 在呈现完全出现之前,就被解雇了。
要解决这个问题,你需要检查在解雇的时间点,检查是否调用了viewDidAppear,如果没有,推迟解雇在 – viewDidAppear。