iOS UIViewController Access the container view controller

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

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;


Got any iOS Question?