本文介绍了注册或登录iOS7后如何显示标签栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我有一个基于选项卡的应用程序,它首先需要从登录页面登录/注册,然后才能看到选项卡栏,我实际上已经使用了大约 3 个小时,但还没有解决方案!

Basically I have a tab based app which involves log in/ sign up from a landing page first before you can see the tabbar,I have literally been on this for about 3 hours with no solutions yet !

所以它更像是:LandingCtrl(tabBarNotvisible)-> LoginCtrl(tabBarNotvisible)-> profile(tabBarvisible)

so its more like: LandingCtrl(tabBarNotvisible)-> LoginCtrl(tabBarNotvisible)-> profile(tabBarvisible)

这是我试过的:

appdelegate.m

appdelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];

    // Initialize tab controllers.  with each tab has its own navigation controller
    ProfileViewController *profileViewController =[[ProfileViewController alloc]init];
    UINavigationController *nav1 = [[UINavigationController alloc]initWithRootViewController:profileViewController];
    [nav1 setTitle:@"Profile"];

    DiscoverViewController *discoverViewController=[[DiscoverViewController alloc]init];
    UINavigationController *nav2 = [[UINavigationController alloc]initWithRootViewController:discoverViewController];
    [nav2 setTitle:@"Discover"];

    RecievedViewController *recievedViewController = [[RecievedViewController alloc]init];
    UINavigationController *nav3 = [[UINavigationController alloc]initWithRootViewController:recievedViewController];
    [nav3 setTitle:@"Recieved"];

    // initialize tabbarcontroller and set your viewcontrollers.
    self.tabBarController = [[UITabBarController alloc]init];
    self.tabBarController.viewControllers=[NSArray arrayWithObjects:nav1,nav2,nav3, nil];

    // Inititalize Navigationcontroller and set root as tabbar.
    self.navBarController = [[UINavigationController alloc]initWithRootViewController:self.tabBarController];

    LandingViewController *landingviewcontroller = [[LandingViewController alloc] init];
    UINavigationController *nVC = [[UINavigationController alloc] initWithRootViewController:landingviewcontroller];
    nVC = [[UINavigationController alloc]initWithRootViewController:landingviewcontroller];
    nVC.navigationBar.barTintColor = [UIColor colorWithRed:0.204 green:0.286 blue:0.369 alpha:1];
    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-100.f, 0) forBarMetrics:UIBarMetricsDefault];
    nVC.navigationBar.tintColor = [UIColor whiteColor];
    nVC.navigationBar.translucent = NO;

    [self.window addSubview:self.tabBarController. view];
    [self.tabBarController presentViewController:nVC animated:YES completion:nil];
    //[self.window setRootViewController:nVC];
    [self.window makeKeyAndVisible];

    return YES;
}

仍然无法让这该死的东西工作,我真的很感激你的帮助,谢谢!!!!!!

Still cant get the darn thing to work, i would really appreciate your help, thanks !!!!!

推荐答案

我正在遵循以下代码.这对我有用,检查一次.您应该先创建登陆页面,然后在登陆页面上创建此逻辑.

I am following below code. This is working for me, check it once. You should create Landing page first then after create this logic on landing page.

NewHomeView *home=[[NewHomeView alloc]initWithNibName:@"NewHomeView_iPad" bundle:nil];
        UIImage *imag=[UIImage imageNamed:@"profile40x40.png"];
        [home setTabBarItem:[[UITabBarItem alloc]initWithTitle:@"Home" image:imag tag:100]];

        BiographyView *biography= [[BiographyView alloc] initWithNibName:@"BiographyView_iPad" bundle:nil];
        UIImage *imag1=[UIImage imageNamed:@"Biography40x40.png"];
        [biography setTabBarItem:[[UITabBarItem alloc]initWithTitle:@"Biography" image:imag1 tag:101]];

        GalleryView *gallery = [[GalleryView alloc] initWithNibName:@"GalleryView_iPad" bundle:nil];
        UIImage *imag2=[UIImage imageNamed:@"Gallery40x40.png"];
        [gallery setTabBarItem:[[UITabBarItem alloc]initWithTitle:@"Gallery" image:imag2 tag:102]];

        VideosView *video = [[VideosView alloc] initWithNibName:@"VideosView_iPad" bundle:nil];
        UIImage *imag3=[UIImage imageNamed:@"Videos40x40.png"];
        [video setTabBarItem:[[UITabBarItem alloc]initWithTitle:@"Videos" image:imag3 tag:103]];


        MoviesView *movies = [[MoviesView alloc] initWithNibName:@"MoviesView_iPad" bundle:nil];
        UIImage *imag4=[UIImage imageNamed:@"Movies40x40.png"];
        [movies setTabBarItem:[[UITabBarItem alloc]initWithTitle:@"Movies" image:imag4 tag:104]];


        NewsView *news = [[NewsView alloc] initWithNibName:@"NewsView_iPad" bundle:nil];
        UIImage *imag5=[UIImage imageNamed:@"news40x40.png"];
        [news setTabBarItem:[[UITabBarItem alloc]initWithTitle:@"News" image:imag5 tag:105]];

        tabController = [[UITabBarController alloc] init];
        [tabController setViewControllers:[NSArray arrayWithObjects:home, biography, gallery,video,movies,news, nil]];

      [self.navigationController pushViewController:tabController animated:YES];

这篇关于注册或登录iOS7后如何显示标签栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 14:14