UIViewController中的Uitabbarcontroller不在appdelegate中

时间:2011-12-14 07:09:04

标签: iphone objective-c ios uitabbarcontroller

如何将UITabbarcontroller集成到不在应用代理中的UIViewController课程中?我想要创建一个登录视图,然后出现在UITabBarController类中创建的UIViewController?任何人都可以建议需要做什么?感谢

2 个答案:

答案 0 :(得分:1)

您仍然可以将UITabBarController放在App Delegate中,当登录完成后,只需告诉应用代理,然后切换它们:

  

self.window.rootViewController = tabBarController;

答案 1 :(得分:-2)

如果您的应用程序是基于导航的应用程序,则创建TabBarController(使用ViewControllers您要添加的数量)并将其添加到导航控制器上,如下所示

UITabBarController *tabBarController = [Utility configureMessagesTabBArController];
self.navigationController.navigationBarHidden=YES;
[self.navigationController pushViewController:tabBarController animated:YES];
[tabBarController release];

这是来自Utility class的 configureMessagesTabBArController 方法

+(UITabBarController *)configureMessagesTabBArController
{
    UITabBarController *tabBarController = [[UITabBarController alloc]init];

    AktuellesViewController *aktuelles_Controller = [[AktuellesViewController alloc]init];
    TermineViewController *termine_Controller = [[TermineViewController alloc]init];
    TopTenViewController *topTen_Controller = [[TopTenViewController alloc]init];
    MediathekViewController *mediathek_Controller = [[MediathekViewController alloc]init];
    KontaktViewController *kontakt_Controller = [[KontaktViewController alloc] init];

    UINavigationController *nav1 = [[UINavigationController alloc]initWithRootViewController:aktuelles_Controller];
    UINavigationController *nav2 = [[UINavigationController alloc]initWithRootViewController:termine_Controller];
    UINavigationController *nav3 = [[UINavigationController alloc]initWithRootViewController:topTen_Controller];
    UINavigationController *nav4 = [[UINavigationController alloc]initWithRootViewController:mediathek_Controller];
    UINavigationController *nav5 = [[UINavigationController alloc]initWithRootViewController:kontakt_Controller];

    nav1.navigationBar.tintColor = [UIColor blackColor];
    nav2.navigationBar.tintColor = [UIColor blackColor];
    nav3.navigationBar.tintColor = [UIColor blackColor];
    nav4.navigationBar.tintColor = [UIColor blackColor];
    nav5.navigationBar.tintColor = [UIColor blackColor];

    [tabBarController setViewControllers:[[NSArray alloc]initWithObjects:nav1,nav2,nav3,nav4,nav5,nil]];

    [nav1 release];
    [nav2 release];
    [nav3 release];
    [nav4 release];
    [nav5 release];

    [aktuelles_Controller release];
    [termine_Controller release];
    [topTen_Controller release];
    [mediathek_Controller release];
    [kontakt_Controller release];

    return tabBarController;
}