OGeek|极客世界-中国程序员成长平台

标题: ios - 注册或登录 iOS7 后如何显示标签栏 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 11:24
标题: ios - 注册或登录 iOS7 后如何显示标签栏

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

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

这是我尝试过的:

appdelegate.m

- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)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"rofile"];

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

仍然无法让该死的东西工作,我非常感谢您的帮助,谢谢!!!!!!



Best Answer-推荐答案


我正在关注以下代码。这对我有用,检查一次。您应该先创建登录页面,然后在登录页面上创建此逻辑。

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

关于ios - 注册或登录 iOS7 后如何显示标签栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25255890/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4