Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 10 UITabBar more items visible after setting title

Tags:

ios

ios10

I have a tab bar in my app, and the tab bar items are subclasses of UITabBarItem. After fetching an update from the server, these tab bar items set their title from code using this line:

[self setTitle:@"SomeText"];

Once this line runs, the tab bar items that were previously hidden (behind the more tab) become visible in the main tabs area, and stack on top of the other tabs. See the screenshot below. This only happens in iOS 10 (beta). Is this a bug in my code or an issue in iOS 10?

I have created a minimal XCode project and posted to Github to demonstrate the issue: https://github.com/RippleAdder/TabStacks

enter image description here

like image 912
Crake Avatar asked Aug 04 '16 20:08

Crake


2 Answers

This happens anytime you programmatically set a tab's Title in iOS 10. I have confirmed that this is a bug in iOS 10 beta. I have opened a bug report and radar: openradar.appspot.com/27749026

I have also posted a Github repo that demonstrates the issue: https://github.com/RippleAdder/TabStacks

like image 100
Crake Avatar answered Nov 01 '22 14:11

Crake


This answer will not solve your particular case but could help others with the same problem.

The problem seems to appear if you're using the UIViewControllers tabBarItem property to set the title. Using the UITabBarController tabBar property instead should resolve the problem.

So instead of (e.g.):

tabBarController.viewControllers[0].tabBarItem.title = @"SomeText";

use:

tabBarController.tabBar.items[0].title = @"SomeText";

Update

We found out that replacing the UITabBarItem is another workaround to this iOS 10 bug:

UITabBarItem *item = tabBarController.viewControllers[0].tabBarItem;
tabBarController.viewControllers[0].tabBarItem = [[UITabBarItem alloc] initWithTitle:@"SomeText" image:item.image tag:item.tag];
like image 42
shady Avatar answered Nov 01 '22 14:11

shady