【发布时间】:2014-06-13 19:28:58
【问题描述】:
我正在开发一个带有 uitabbarcontoller(带有 5 个 uiviewcontrollers)和 uinavigation 栏的应用程序。 我已经在应用程序中创建了所有这些,但是当我运行它时,它不起作用
这是 AppDelegate.m 类:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UINavigationController *navCon = [[UINavigationController alloc] init];
UITabBarController *tabBarController = [[UITabBarController alloc] init];
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
HomePageView *viewController = [[HomePageView alloc] init];
FeedViewController *feedViewController=[[FeedViewController alloc]init];
ProfileViewController *profileViewController=[[ProfileViewController alloc]init];
PlayViewController *playViewController = [[PlayViewController alloc]init];
ListeningSessionViewController *listeningSessionViewController= [[ListeningSessionViewController alloc]init];
RecievedViewController *recievedViewController =[[RecievedViewController alloc]init];
tabBarController.viewControllers=[NSArray arrayWithObjects:feedViewController,profileViewController,playViewController,listeningSessionViewController,recievedViewController, nil];
//navigating to the UITabBarController that you created
[navCon pushViewController:tabBarController animated:YES];
[navCon pushViewController:viewController animated:NO];
return YES;
}
【问题讨论】:
-
为什么要将标签栏控制器推到导航控制器上?每个选项卡都应根据需要有自己的导航控制器。
-
@rmaddy 我删除了该行,但它仍然无法正常工作
-
“不起作用”这些词是开发人员可以使用的最无用的词。这是没有意义的。请更新您的问题,详细说明您想要发生的事情并解释实际发生的事情。具体一点。
-
我没有看到您将 tabBarController 添加到任何地方的窗口中。尝试将
return YES之前的最后两行替换为self.window.rootViewController = tabBarController
标签: ios objective-c uinavigationcontroller uitabbarcontroller appdelegate