Gaurav Sharma
Gaurav Sharma

Reputation: 2770

Access UITabBarController to assign action via Storyboards

Without storyboards, I can simply assign the UITabBarController.delegate = self (in AppDelegate, for example). This lets me handle what happens when a UITabBarButton on the UITabBar is pressed.

However, I'm now using storyboards, where my UIViewController is contained in a UINavigationController, which is contained in a UITabBarController.

What's the best way to access this parent UITabBarController in code? I'd like to do this so I can assign a delegate to it. When the user presses a button in the UITabBar, I want to take an action in my contained UIViewController.

Upvotes: 0

Views: 15

Answers (1)

Dan Leonard
Dan Leonard

Reputation: 3395

self.navigationController?.tabBarController

Upvotes: 1

Related Questions