【问题标题】:Issues in tabbar title in iPhone?iPhone中标签栏标题的问题?
【发布时间】:2012-10-05 10:59:01
【问题描述】:

目前我正在使用 iPhone 应用程序,我有四个屏幕,如登录、A、B 和 c 等。 用户在登录屏幕输入用户名和密码字段,然后按登录按钮

-(void)LoginButtonMethod
{

    A *a = [[A alloc]init];
    B *b = [[B alloc]init];
    C *c = [[C alloc]init];

    UINavigationController *navi1 = [[UINavigationController alloc] initWithRootViewController:a];
    UINavigationController *navi2 = [[UINavigationController alloc] initWithRootViewController:b];
    UINavigationController *navi3 = [[UINavigationController alloc] initWithRootViewController:c];

    UITabBarController *TabBar = [[UITabBarController alloc] init];
    TabBar.delegate = self;
    TabBar.viewControllers = [NSArray arrayWithObjects:navi1, navi2, navi3, nil]; 
    navi1.tabBarItem.title=@"A";
    navi2.tabBarItem.title=@"B";
    navi3.tabBarItem.title=@"C";

    [self.navigationController pushViewController:TabBar animated:YES]; 
}

然后我为每个类设置导航栏标题,例如 A 为 facebook,b 为 yahoo,c 为 google。

最后我运行应用程序,标签栏标题显示在 A,B,C 然后我选择第三个标签栏项目(C),当时标签栏标题更改谷歌。 我无法解决这个问题,请帮助我。

提前致谢

【问题讨论】:

  • 我很困惑,你想让第三个名字(根据你的 C)作为谷歌来吗?
  • 您是否在 View Did Load 中为每个控制器设置了 self.title = @"Your Title" 可能这会解决您的问题。或者你可以只为你遇到问题的 ViewController 添加
  • 这应该可以检查两个类中的断点。

标签: iphone ios uinavigationbar title tabbar


【解决方案1】:

Apple 在其开发者文档中声明如下:

    "You never want to push a tab bar controller onto the navigation stack of a navigation controller. Doing so creates an unusual situation whereby the tab bar appears only while a specific view controller is at the top of the navigation stack. Tab bars are designed to be persistent, and so this transient approach can be confusing to users."

尝试展示它

[self presentModalViewController:tabBar animated:YES];

【讨论】:

    【解决方案2】:

    您可以通过以下方式将 Tabbar 推送到控制器

    任一

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

    [self presentModalViewController:tabBar animated:YES];
    

    希望这能解决您的问题

    【讨论】:

      【解决方案3】:

      在这

      - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

      每个视图Controller的方法放如下代码..

      self.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Comment" image:[UIImage imageNamed:@"Icon-AddComment.png"] tag:0];
      
      self.navigationItem.title = @"Comment";
      

      有效

      【讨论】:

        猜你喜欢
        • 2010-12-03
        • 1970-01-01
        • 2023-04-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-04-08
        • 1970-01-01
        相关资源
        最近更新 更多