I am trying to use setRootViewController in swift from a UIViewController not from app delegate.
I found some questions on stack overflow but everywhere they have explained to do it from app delegate. However, I want to do it from a UIViewController and set UITabBarController as a rootViewController
This is how i did it in objective c
UITabBarController *main = [self.storyboard instantiateViewControllerWithIdentifier:@"main"];
[[[[UIApplication sharedApplication] delegate] window] setRootViewController:main];
I would like to do the same in swift. Is there any way to do it in swift or do i need to use segue?
我使用下面的代码行:
UIApplication.sharedApplication().delegate?.window??.rootViewController = mainViewController
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.