如何在注册或登录iOS7后显示标签栏?



基本上我有一个基于标签的应用程序,涉及登录/注册从一个登陆页面之前,你可以看到标签栏,我已经在这上面大约3个小时还没有解决方案!

更像是:LandingCtrl(tabBarNotvisible)-> loginctl (tabBarNotvisible)-> profile(tabBarvisible)

这是我尝试过的:

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;
}

仍然不能得到该死的东西工作,我真的很感激你的帮助,谢谢!!!!!

我遵循下面的代码。这对我有用,检查一次。你应该先创建登陆页,然后在登陆页上创建这个逻辑。

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];

你应该在AppDelegate.m

if(user logged in){
     // show tab bar
    [self.window addSubview:self.tabBarController.view];
    [self.window makeKeyAndVisible];
}
else {
    LandingViewController *landingviewcontroller = [[LandingViewController alloc] init];
    UINavigationController *nVC = [[UINavigationController alloc] initWithRootViewController:landingviewcontroller];
    nVC = [[UINavigationController alloc]initWithRootViewController:landingviewcontroller];
    [self.window addSubview: nVC.view];
    [self.window makeKeyAndVisible];
}

当用户登录时,将其保存在存储中,以便下次应用程序从头启动时进入if语句。

还没有编译…但是你们应该明白

最新更新