[英]IOS: dismiss two viewController
I have three viewController 我有三个viewController
First, Second and Third 第一,第二和第三
from Second to open Third I use 从第二到第三我用
Third *third = [[Third alloc]initWithNibName:@"Third" bundle:nil];
[self presentModalViewController:third animated:YES];
[third release];
Now I want return from third to first; 现在我想从第三到第一回来; then I set in viewDidAppear in second this code:
然后我在第二个代码中设置viewDidAppear:
[self dismissModalViewControllerAnimated:NO];
but for 1 second I see Second and I don't want watch it...how can I do? 但是1秒钟我看到第二个,我不想看它......我该怎么办?
You need to dismiss third view controller first and then second Viewcontroller. 您需要首先关闭第三个视图控制器,然后关闭第二个Viewcontroller。 Do the following code when you want to go first view controller.
当您想要第一个视图控制器时,请执行以下代码。
-(void)goToFirstView{
UIViewController *vc = [self parentViewController];
// UIViewController *vc = [self presentingViewController]; //ios 5 or later
[self dismissModalViewControllerAnimated:NO];
[vc dismissModalViewControllerAnimated:YES];
}
How is the Third modal view being dismissed in the first place? 第三种模式观点如何被首先解雇? Perhaps by the user touching a 'Done' button?
也许用户触摸“完成”按钮? If so, it is in the handler for the button that you want to dismiss both.
如果是这样,那么它就是你想要解除它们的按钮的处理程序。
You can dismiss both as: 你可以将两者都解雇为:
[self dismissModalViewControllerAnimated: YES];
[self.presentingViewController dismissModalViewControllerAnimated: NO];
This happens coz viewDidAppear is called everytime before the view appears so as soon as it appears you dismiss it and it disappears.. 发生这种情况时,每次在视图出现之前都会调用viewDidAppear,因此只要它出现就会解除它并消失。
I don't think what u are trying to do can be achieved with modalViewControllers... instead use a navigationController and keep adding your viewcontrollers onto the stack and when you want to goto the First view controller just call 我不认为你想要做什么可以通过modalViewControllers实现...而是使用navigationController并继续将viewcontrollers添加到堆栈中,当你想转到第一个视图控制器时只需调用
[self.navigationController popToRootViewControllerAnimated:YES];
EDIT
: EDIT
:
just thought of it this can be achieved by using delegation.. you make second the delegate of third and as soon you dismiss the thirdviecontroller send the delegate a message.In this message call [self dismissModalViewControllerAnimated:NO];
只是想到这可以通过使用委托来实现..你做第二个委托第三个,并且一旦你解雇thirdviecontroller发送委托一个消息。在这个消息调用
[self dismissModalViewControllerAnimated:NO];
.. and you are done.. (pretty easy if you know delegation.) ..而且你已经完成..(如果你知道代表团,那就太容易了。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.