UINavigationController与UITabBarController同时实现!~!适合小新手哦!

来源:互联网 发布:淘宝买家好评率100% 编辑:程序博客网 时间:2024/06/11 03:36


    

    TestOneViewController *homeController = [[TestOneViewControlleralloc] init];

    homeController.title = @"蓝天l风烨堞";

    

    UINavigationController *navController1 = [[UINavigationControlleralloc] initWithRootViewController:homeController];

    

    

    

    TestTwoViewController *messageController = [[TestTwoViewControlleralloc] init];

    messageController.title = @"信息";

    UITabBarItem *item1 = [[UITabBarItemalloc] initWithTabBarSystemItem:UITabBarSystemItemHistorytag:0];

    messageController.tabBarItem = item1;

    

    UINavigationController *navController2 = [[UINavigationControlleralloc] initWithRootViewController:messageController];

    

    

    

    TestThirdViewController *mineController = [[TestThirdViewControlleralloc] init];

    mineController.title = @"我的资料";

    UITabBarItem *item2 = [[UITabBarItemalloc] initWithTabBarSystemItem:UITabBarSystemItemContactstag:0];

    mineController.tabBarItem = item2;

    

    UINavigationController *navController3 = [[UINavigationControlleralloc] initWithRootViewController:mineController];

    

    

    

    TestThirdViewController *searchController = [[TestThirdViewControlleralloc] init];

    searchController.title = @"搜索";

    UITabBarItem *item3 = [[UITabBarItemalloc] initWithTabBarSystemItem:UITabBarSystemItemSearchtag:0];

    searchController.tabBarItem = item3;

    

    UINavigationController *navController4 = [[UINavigationControlleralloc] initWithRootViewController:searchController];

    

    

    

    TestThirdViewController *moreController = [[TestThirdViewControlleralloc] init];

    moreController.title = @"更多";

    UITabBarItem *item4 = [[UITabBarItemalloc] initWithTabBarSystemItem:UITabBarSystemItemMoretag:0];

    moreController.tabBarItem = item4;

    

    UINavigationController *navController5 = [[UINavigationControlleralloc] initWithRootViewController:moreController];

    

    

    

    NSArray *controllers = [NSArrayarrayWithObjects:navController1,navController2,navController3,navController4,navController5,nil];

    

    UITabBarController *tabBarController=[[UITabBarControlleralloc]init];

    tabBarController.viewControllers = controllers;

    

    

    [self.window setRootViewController:tabBarController];

    [self.windowmakeKeyAndVisible];

    

    return YES;

    

    

    

0 0
原创粉丝点击