连续关闭 2 个 ViewController [英] Dismissing 2 ViewController consecutively

查看:20
本文介绍了连续关闭 2 个 ViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了 2 种方法连续关闭 2 个视图控制器,但只有其中一个被关闭,而不是第二个

I try 2 ways to dismissed 2 viewcontrollers consecutively but only one of them got dismissed not the second one

方法 1

-(void) LoginDone:(NSNotification *)notif 
 {
 [self dismissViewControllerAnimated:YES completion:NULL];   //previous viewcontroller
 [self dismissViewControllerAnimated:YES completion:NULL];   //current viewcontroller
  }

方法2

-(void) LoginDone:(NSNotification *)notif 
{
[self dismissViewControllerAnimated:YES completion:NULL];
 [[NSNotificationCenter defaultCenter] postNotificationName:@"LoginDone2" object:nil];

 }

-(void) LoginDone2:(NSNotification *)notif 
{
     [self dismissViewControllerAnimated:YES completion:NULL];


 }

我需要找到一种方法来连续关闭前一个视图控制器和当前视图控制器.

I need to find out a way to dismiss both the previous viewcontroller and current viewcontroller consecutively.

推荐答案

这是一个老问题,但它似乎正是我目前遇到的问题.这是我所做的:

This is now an old question, but it seems to be exactly the problem I am having presently. Here what I did:

    [self.presentingViewController.presentingViewController
     dismissViewControllerAnimated:YES completion:nil];

它对我有用.我希望它对某人有用.

And it works for me. I hope it can be useful to someone.

这篇关于连续关闭 2 个 ViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆