![](/img/trans.png)
[英]ios present view controller immediately after dismissing a previous one
[英]iOS - Present View controller immediately after dismissing an other view controller
我有三个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的代码。
我知道我们所有人都总是将nil
作为完成代码...但是它确实有一些用处。 我向你保证。
[self dismissViewControllerAnimated:YES completion:^{
//code to be executed with the dismissal is completed
// for example, presenting a vc or performing a segue
}];
这是我用来关闭Facebook登录视图控制器的那个。
UIViewController *theTrick = self.presentingViewController;
UIViewController *toPresent = [self.storyboard instantiateViewControllerWithIdentifier:@"toPresentViewController"];
[self dismissViewControllerAnimated:YES completion:^{
[theTrick presentViewController:toPresent animated:YES completion:nil];
}];
感谢您的帮助。 在介绍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];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.