iOS Access the container view controller


Example

When the view controller is presented within a tab bar controller, you can access the tab bar controller like this:

Swift

let tabBarController = viewController.tabBarController

Objective-C

UITabBarController *tabBarController = self.tabBarController;

When the view controller is part on an navigation stack, you can access the navigation controller like this:

Swift

let navigationController = viewController.navigationController

Objective-C

UINavigationController *navigationController = self.navigationController;