开发者社区 问答 正文

uitabbar controller中标题显示的问题

ios

iphone

使用以下代码创建了uitabbarview controller
在uitabbarview controller中我想为每一个视图显示标题
怎么样为每个视图添加标题呢(标题栏项目)?

myTabBarController = [[UITabBarController alloc] init];

    MyDialerViewController *aDialerViewController = [[MyDialerViewController alloc]init];
    MyCallLogViewController *aCallLogViewController = [[MyCallLogViewController alloc] init];
    TemplateViewController *aTemplateViewController = [[TemplateViewController alloc] init];    


    NSArray* controllers = [NSArray arrayWithObjects:aDialerViewController, aCallLogViewController, aTemplateViewController, nil];
    myTabBarController.viewControllers = controllers;
    myTabBarController.delegate = self;
    myTabBarController.selectedIndex = 0;

    [controllers release];
    [aDialerViewController release];
    [aCallLogViewController release];
    [aTemplateViewController release];

    [self.window addSubview:myTabBarController.view];

    [self.window makeKeyAndVisible];

展开
收起
爵霸 2016-05-27 11:25:57 2002 分享 版权
1 条回答
写回答
取消 提交回答
  • 在appDelegate里面直接设置navcontroller的标题。同时也在viewcontroller里面的viewDidLoad 中设置。

    aDialerViewController.title = NSLocalizedString(@"Dialer Title", @"Dialer Title");
    aCallLogViewController.title = @"Title";
    aTemplateViewController.title = @"Title";
    2019-07-17 19:17:30
    赞同 展开评论
问答分类:
问答地址: