English 中文(简体)
标语
原标题:tab bar item title programatically not showing in objective c

我尝试以方案方式创建刺铁矿石控制器,但我不能确定对塔巴物品的所有权。 在我提出申请时,我看不到标题。 我的法典在这里。 请帮助我,问题是什么?

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.

myTabBarController = [[UITabBarController alloc] init];        
view2Controller = [[testView alloc] init];   
view3Controller = [[testView2 alloc] init];   
view4Controller = [[testView3 alloc] init];   
view5Controller = [[testView4 alloc] init];   
view6Controller = [[testView5 alloc] init];   


myTabBarController.viewControllers = [NSArray arrayWithObjects: view2Controller, view3Controller,view4Controller,view5Controller,view6Controller,nil]; 
 UITabBarItem *tabItem = [[[myTabBarController tabBar] items] objectAtIndex:1];
 [tabItem setTitle:@"theTitle"];

[self.view addSubview:myTabBarController.view];    
myTabBarController.selectedIndex=0;

}
问题回答

Set the title of ur viewcontroller in side viewcontroller s viewwillappear/disappear and it will be displayed in ur tabbaritem.

页: 1 UIViewController,其中反映的是何时将其推入NavUIigationControllerTabBarController。 但是,在把标题放在其中之前,你应当确定标题。

<代码>init一般来说是确定标题的良好地方。

- (id)init {
    // ... other code including check for self
    self.title = @"My Title";
    return self;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {

        // self.title = @"My Title";
    }

    self.title = @"My Title";
    return self;
}

以上代码在表B控制器的每个次目中使用。

这可能有助于。

use this code

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title=@"FREE BOOKS";
        self.tabBarItem.image = [UIImage imageNamed:@"first"];
    }
    return self;
}

Here是分法的理论,该理论应有助于你实现你想要达到的确切功能。 源代码的下载和直接操作,如果标题正确,你可以跟踪辅导,了解UITab BarController的流量。

override func viewDidLoad() {
    super.viewDidLoad()

    DispatchQueue.main.async {
        self.tabBar.items?[0].title = "Title"
    }

}

页: 1

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    self.tabBar.items?[0].title = "Title"

}




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签