简体   繁体   中英

UITabBarControllerDelegate - Where to put the Code?

I am writing an iPhone app with the following structure (created in storyboard)

UIView --> TabBarController --> 1.NavigationController --> UITableView --> UIView
                                2.NavigationController --> UITableView --> UIPageController --> UIView
                                3.NavigationController --> UIView
                                ...
                                7.NavigationController --> UIView

When a TabBarItem is clicked, I want the page to pop to the root view.

I know I need to implement a UITabBarControllerDelegate with the method:

- (void)tabController:(UITabBarController *)tabController didSelectViewController: (UIViewController *)viewController

I don't understand where to put this method and whether to make AppDelegate the UITabBarDelegate, or to make my customTabBarController class the delegate.

Also, where do I make the tabBarController.delegate = self call?

I'm a serious noob, please help :)

如果您的AppDelegate具有对UITabBarController的引用,则将其作为您的委托。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM