[英]iOS - Present View controller immediately after dismissing an other view controller
I have three View Controller VC1,VC2 and VC3. 我有三个View Controller VC1,VC2和VC3。
VC2 is of a 3rd party library and it is presented on VC1. VC2是第三方库,在VC1上提供。
Then VC2 dismissed itself and send a callback to VC1 and VC1 try to present VC3 on itself but failed. 然后,VC2退出自身,并向VC1发送回调,而VC1尝试在其自身上显示VC3,但失败了。
Is there some way to present VC3 immediately after dismissing VC2 ? 退出VC2之后,有什么方法可以立即显示VC3吗?
-(void)onDismisLoginVC{
MessageVC *messageVC = [[MessageVC alloc] initWithNibName:@"MessageVC" bundle:nil];
[self.navigationController presentViewController:messageVC animated:YES completion:NULL];
}
Unfortunately I can not use ^completion
block of dismissing presented viewcontroller in VC2 because I am just receiving a callback to this method and can't edit code of VC2. 不幸的是,我无法在VC2中使用
^completion
块来消除提供的viewcontroller,因为我刚刚收到此方法的回调,并且无法编辑VC2的代码。
I know we all always put nil
for the completion block... but it actually does have some use. 我知道我们所有人都总是将
nil
作为完成代码...但是它确实有一些用处。 I assure you. 我向你保证。
[self dismissViewControllerAnimated:YES completion:^{
//code to be executed with the dismissal is completed
// for example, presenting a vc or performing a segue
}];
This is the one I use to dismiss a Facebook login view controller. 这是我用来关闭Facebook登录视图控制器的那个。
UIViewController *theTrick = self.presentingViewController;
UIViewController *toPresent = [self.storyboard instantiateViewControllerWithIdentifier:@"toPresentViewController"];
[self dismissViewControllerAnimated:YES completion:^{
[theTrick presentViewController:toPresent animated:YES completion:nil];
}];
Thanks for help guys. 感谢您的帮助。 Adding a little bit delay before presenting VC3 solved the problem.
在介绍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.