【问题标题】:Titles are not showing in the navigation bar iphone app标题未显示在导航栏 iphone 应用程序中
【发布时间】:2013-04-12 10:36:29
【问题描述】:

主屏幕后不显示标题。我在第一个屏幕之后放了UITabBarController。第一个屏幕没有UITabBarController。我不确定我实现选项卡的方式。

我已经通过self.title = @"title" 在每个视图控制器中设置了标题。标题正确显示在选项卡项中。

AppDelegate.m:

 UIViewController *loginView= [[[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil] autorelease];

UINavigationController *loginViewNavController = [[UINavigationController alloc] initWithRootViewController:loginView ];

self.navigationController = loginViewNavController;

self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];

LoginViewController.m:

-(IBAction)navigateMainMenu:(id)sender{

tabBarController = [[UITabBarController alloc] init];

MyAccountsViewController *vc1 = [[MyAccountsViewController alloc] initWithNibName:@"MyAccountsViewController" bundle:nil];
DepositsViewController *vc2 = [[DepositsViewController alloc] initWithNibName:@"DepositsViewController" bundle:nil];
MoreViewController *vc3 = [[MoreViewController alloc] initWithNibName:@"MoreViewController" bundle:nil];
PayTransViewController *vc4 = [[PayTransViewController alloc]init];

NSArray* controllers = [NSArray arrayWithObjects:vc1,vc4, vc2, vc3, nil];
tabBarController.viewControllers = controllers;

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

[mainMenuViewController release];

【问题讨论】:

    标签: iphone uinavigationcontroller uitabbarcontroller title


    【解决方案1】:

    我建议你不要在导航控制器中使用 tabbarcontroller。如果您使用的是 tabbarcontroller,它应该是 rootViewcontroller。

    【讨论】:

      【解决方案2】:

      如果你设置 self.title = @"Title"。该标题将在 navController 标题中设置。但是在您的 TabBarController 中,每个项目都是 ViewController。不是导航控制器。

      问题:你在这一行发布的内容 [mainMenuViewController release];

      【讨论】:

        【解决方案3】:

        主要用以下技巧显示标题:-

        1. Self.title=@"Your Titile";
        
        2. self.navigationItem.title=@"your Title";
        
        3. when you using UItabBarController you can set Particular Viewcontroller as par your code Title like:- 
        
          vc1.title=@"your Title";
          vc2.title=@"your Title";
          vc3.title=@"your Title";
          vc4.title=@"your Title";
        

        【讨论】:

        • 1 对我不起作用。但是2 有效。你能告诉我为什么吗?谢谢。
        猜你喜欢
        • 2018-04-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-23
        • 2016-09-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多