加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

不要在Iphone SDK的第一个登录页面显示标签栏

发布时间:2020-12-14 19:03:07 所属栏目:百科 来源:网络整理
导读:我在我的应用程序中实现了Tab栏控制器.但我的第一页是登录视图.所以,我不想在它上面显示标签栏.我通过隐藏该视图上的标签栏来完成此操作. 但是现在,当我选择第一个选项卡时,它总是作为登录页面进入根视图控制器. //for home tab.. UINavigationController *n
我在我的应用程序中实现了Tab栏控制器.但我的第一页是登录视图.所以,我不想在它上面显示标签栏.我通过隐藏该视图上的标签栏来完成此操作.

但是现在,当我选择第一个选项卡时,它总是作为登录页面进入根视图控制器.

//for home tab..


    UINavigationController *nav1 = [[UINavigationController alloc] init];

    UIViewController *viewController1;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        viewController1 = [[[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil] autorelease];
    } else
    {
        viewController1 = [[[LoginViewController alloc] initWithNibName:@"LoginViewController_iPad" bundle:nil] autorelease];
    }

    nav1.viewControllers = [NSArray arrayWithObjects:viewController1,nil];



    //for account tab...
    UINavigationController *nav2 = [[UINavigationController alloc] init];
    UIViewController *viewController2;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        viewController2 = [[[AccountView alloc] initWithNibName:@"AccountView_iPhone" bundle:nil] autorelease];
    } else
    {
        viewController2 = [[[AccountView alloc] initWithNibName:@"AccountView_iPad" bundle:nil] autorelease];
    }
    nav2.viewControllers = [NSArray arrayWithObjects:viewController2,nil];

    //for links tab...
    UINavigationController *nav3 = [[UINavigationController alloc] init];
    UIViewController *viewController3;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        viewController3 = [[[LinksView alloc] initWithNibName:@"LinksView_iPhone" bundle:nil] autorelease];
    } else
    {
        viewController3 = [[[LinksView alloc] initWithNibName:@"LinksView_iPad" bundle:nil] autorelease];
    }
    nav3.viewControllers = [NSArray arrayWithObjects:viewController3,nil];

    //for about us tab...
    UINavigationController *nav4 = [[UINavigationController alloc] init];
    UIViewController *viewController4;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        viewController4 = [[[AboutUsView alloc] initWithNibName:@"AboutUsView_iPhone" bundle:nil] autorelease];
    } else
    {
        viewController4 = [[[AboutUsView alloc] initWithNibName:@"AboutUsView_iPad" bundle:nil] autorelease];
    }
    nav4.viewControllers = [NSArray arrayWithObjects:viewController4,nil];


    self.tabBarController = [[[UITabBarController alloc] init] autorelease];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:nav1,nav2,nav3,nav4,nil];

    self.tabBarController.tabBar.tintColor = [UIColor blackColor];

    //self.tabBarController.tabBar.tintColor = [UIColor colorWithRed:237.0/255.0 green:208.0/255.0 blue:0.0/255.0 alpha:1.0];

    self.window.rootViewController=self.tabBarController;

我怎么解决这个问题?

解决方法

只需将viewController m指定给UINavigationController,如下所示.

UINavigationController *nav1 =[[UINavigationController alloc]initWithRootViewController:viewController1];

UINavigationController *nav2 =[[UINavigationController alloc]initWithRootViewController:viewController2];

UINavigationController *nav3 =[[UINavigationController alloc]initWithRootViewController:viewController3];

UINavigationController *nav4 =[[UINavigationController alloc]initWithRootViewController:viewController4];

然后在tabbar中分配与您的代码相同的..

self.tabBarController.viewControllers = [NSArray arrayWithObjects:nav1,nil];
self.window.rootViewController = self.tabBarController;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读