I have two view controllers which are defined in storyboard as,
UIViewController -> (Show Detail Segue) -> UITabBarController
My problem is; I am using a library called netfox
to debug my HTTP
requests. And this librarie's UI
is being triggered by Shake Gesture
. But when I come to the UITabBarController
Shake Gesture
on the simulator does not work at first time. At the second time it dismisses the ViewController
that is currently on the screen and obviously a child of UITabBarController
and goes back to the initial UIViewController
. This is exactly like connecting two ViewController
s with modal
segue and calling self.dismiss()
from the child one.
I tried to change rootViewController
of the UIApplication
by,
UIApplication.shared.keyWindow.rootViewController = self
in the viewDidLoad()
method of the UITabBarController
and it worked. However, for this solution, the items(buttons, titles) in the UINavigationBar
of any UINavigationController
that is the child of UITabBarController
are missing.
I have no idea why this is happening. If someone helps me while I am solving this, I would be really appreciated.
Instead of using
self.performSegue(withIdentifier:_)
calling this in the UIViewController
have worked:
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = mainStoryboard.instantiateViewControllerWithIdentifier("tabBarcontroller") as UITabBarController
UIApplication.sharedApplication().keyWindow?.rootViewController = viewController;
Respect to this answer.