UIViewController 中的 Uitabbarcontroller 不在 appdelegate 中

发布于 2024-12-21 03:28:18 字数 191 浏览 1 评论 0原文

如何将 UITabbarcontroller 集成到 UIViewController 类中而不是应用程序委托中?我本来应该创建一个登录视图,然后出现在 UIViewController 类中创建的 UITabBarController ?谁能建议需要做什么?谢谢

How do I integrate a UITabbarcontroller in a UIViewController class not in the app delegate? I was suppose to make a login view and after it the UITabBarController appears which was created in a UIViewController class? Can anyone suggest what needs to be done? thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜味拾荒者 2024-12-28 03:28:18

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

self.window.rootViewController=tabBarController;

You can still put the UITabBarController in the App Delegate, when the login is done, just tell the app delegate, and switch the them:

self.window.rootViewController=tabBarController;

智商已欠费 2024-12-28 03:28:18

如果您的应用程序是基于导航的应用程序,则创建 TabBarController(以及要添加多少个 ViewController)并将其添加到导航控制器上,就像这里

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

是实用程序类中的 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;
}

if your Application is Navigation Based App, then Create TabBarController(with ViewControllers how many you want to add) and add it on Navigation Controller, like this

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

here is configureMessagesTabBArController Method from Utility class

+(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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文