Hide back button in tabbar navigation controller

原本只有使用navigation bar, 使用下面的 code 是正常:

[self.navigationItem setHidesBackButton:YES];
[self.navigationItem setTitle:NSLocalizedString(@"Camera",@"")];

後來增加了 Tab bar 後,左上角的 back 就出來了,set title 也失敗。類似的失敗畫面:

 

解法如下:

You can set all the UITabBar icons in an easy way. You can do this in your viewWillAppear:method:

[[self.tabBarController.tabBar.items objectAtIndex:0] setTitle:NSLocalizedString(@"BotonMapas", @"comment")];

[[self.tabBarController.tabBar.items objectAtIndex:1] setTitle:NSLocalizedString(@"BotonRA", @"comment")];

[[self.tabBarController.tabBar.items objectAtIndex:2] setTitle:NSLocalizedString(@"BotonEstado", @"comment")];

[[self.tabBarController.tabBar.items objectAtIndex:3] setTitle:NSLocalizedString(@"LabelInfo", @"comment")];

Swift 3.1 Solution

self.tabBarController?.tabBar.items?[0].title = NSLocalizedString("BotonMapas", comment: "comment")
self.tabBarController?.tabBar.items?[1].title = NSLocalizedString("BotonRA", comment: "comment")
self.tabBarController?.tabBar.items?[2].title = NSLocalizedString("BotonEstado", comment: "comment")
self.tabBarController?.tabBar.items?[3].title = NSLocalizedString("LabelInfo", comment: "comment")

 

 

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *