首页 文章

iOS - 在解除其他视图控制器后立即显示View控制器

提问于
浏览
0

我有三个View Controller VC1,VC2和VC3 .

VC2是第三方库,它在VC1上呈现 .

然后VC2解散自己并向VC1发送回调,VC1尝试向自己呈现VC3但失败了 .

解雇VC2后有没有办法立即呈现VC3?

-(void)onDismisLoginVC{

    MessageVC *messageVC = [[MessageVC alloc] initWithNibName:@"MessageVC" bundle:nil];
    [self.navigationController presentViewController:messageVC animated:YES completion:NULL];

}

不幸的是我不能在VC2中使用 ^completion 块解除显示的viewcontroller,因为我只是接收到这个方法的回调而无法编辑VC2的代码 .

3 回答

  • 6

    我知道我们总是将 nil 用于完成块...但它确实有一些用处 . 我向你保证 .

    [self dismissViewControllerAnimated:YES completion:^{
        //code to be executed with the dismissal is completed
        // for example, presenting a vc or performing a segue
        }];
    
  • 5

    这是我用来解雇Facebook登录视图控制器的那个 .

    UIViewController *theTrick = self.presentingViewController;
    UIViewController *toPresent = [self.storyboard instantiateViewControllerWithIdentifier:@"toPresentViewController"];
    
    [self dismissViewControllerAnimated:YES completion:^{
        [theTrick presentViewController:toPresent animated:YES completion:nil];
    }];
    
  • -2

    谢谢你的帮助 . 在呈现VC3之前添加一点延迟解决了这个问题 .

    -(void)onDismisLoginVC{
    
    [self performSelector:@selector(presentMessageVC) withObject:self afterDelay:1];
    
    }
    
    -(void)presentMessageVC
    {
    
    MessageVC *messageVC = [[MessageVC alloc] initWithNibName:@"MessageVC" bundle:nil];
    [self.navigationController presentViewController:messageVC animated:YES completion:NULL];
    
    }
    

相关问题