![](/img/trans.png)
[英]How to present a view controller that is in the “main” storyboard from a view controller that isn't in the storyboard but is created programmatically?
[英]dismiss view controller that was present on storyboard programmatically
我有 3 个 ViewController、 firstVC
、 secondVC
和thirdVC
。
在firstVC
我有一个带有Present Modally
segue 的按钮,用于呈现secondVC
。
在secondVC
我有一个按钮显示thirdVC
。
在thirdVC
我有一个按钮可以关闭两个 VC( secondVC
和thirdVC
)。
我试过这样做:
NSNotificationCenter
发布在secondVC
上调用此方法的通知:
-(void)dismissCalendarView
{
[self dismissViewControllerAnimated:YES completion:nil];
}
但它不起作用。
谢谢!
尝试这个 :
self.presentingViewController?.presentingViewController?.dismissViewControllerAnimated(true, completion: nil)
[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
尝试这个。
如果 FirstVC 是 rootviewController ..
[self.navigationController popToRootViewControllerAnimated:true];
如果不,
[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.