I have a UITabBarController
with three tabs. When a certain one is pressed, I'd like the user to immediately see a person view controller (an instance of the ABPersonViewController
class).
I don't want to just use the presentViewController()
method with a person view controller as a parameter because this results in a lag, when the user can see the underlying view controller from which it's presented.
I also can't make the view controller inherit from ABPersonViewController
, because it's set by Apple so that it can't be subclassed. Is there a way I can accomplish this?
Thanks to JAL's answer:
func tabBarController(tabBarController: UITabBarController, shouldSelectViewController viewController: UIViewController) -> Bool {
let navViewController = viewController as! UINavigationController
// First, check to see if the view controller is the one you want to override
if let myViewController = navViewController.viewControllers[0] as? ThirdViewController {
let abpvc = ABPersonViewController()
abpvc.personViewDelegate = self
self.navigationController?.pushViewController(abpvc, animated: true)
return false
}
return true
}