简体   繁体   English

UITabBarControllerDelegate-将代码放在哪里?

[英]UITabBarControllerDelegate - Where to put the Code?

I am writing an iPhone app with the following structure (created in storyboard) 我正在编写具有以下结构的iPhone应用程序(在情节提要中创建)

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. 单击TabBarItem时,我希望页面弹出到根视图。

I know I need to implement a UITabBarControllerDelegate with the method: 我知道我需要使用以下方法实现UITabBarControllerDelegate

- (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. 我不知道在哪里放置此方法,以及是否使AppDelegate成为UITabBarDelegate或使我的customTabBarController类成为委托。

Also, where do I make the tabBarController.delegate = self call? 另外,在哪里可以使tabBarController.delegate = self调用?

I'm a serious noob, please help :) 我是一个认真的菜鸟,请帮忙:)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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