disabled UITabBarItem appears as enabled after tabbar customization

Hi,


I use a tabbar in combination with a tabbarcontroller in my app (Universal App (iPhone, iPad), XCode Version 9.4.1, Deployment Target 10.0).


The tabbar item property "isEnabled" is toggled programmatically. E.g. if a tabbar is flaged as isEnabled = false than it is automatically displayed as disabled (grey) and when the user taps on it has no effect.


Evertything works like expected until the user uses the built-in tabbar customization item ("..." my app has more then 4 tabbar items). As soon as the user customizes one of the items position, all tabbar items change their state (visual) as if they are all suddenly enabled. After the user ends the tabbar customization the tabbar items still all appear in enabled state although those who were disabled before are still flagged as disabled. When tabbing on one of the disabled item they do not trigger anything as expected. But why are those disabled items displayed as enabled? Hidding the hole tabbar and displaying it again, hoping that the items will be redrawn in a correct manner, does not solve this issue.



Many thanks in advance.

Regards

Hanno Gräser

Replies

What you have described happened on my iOS simulator (Target iOS 12.2) with Xcode 10.2 .


And as far as I tried, you need to tell iOS that the property `isEnabled` has changed (though it is not changed from `false`).


class MyTabBarController: UITabBarController, UITabBarControllerDelegate {
    override func viewDidLoad() {
        self.delegate = self
    }
    
    func tabBarController(_ tabBarController: UITabBarController, didEndCustomizing viewControllers: [UIViewController], changed: Bool) {
        for vc in viewControllers {
            //Tell iOS that `isEnabled` property has changed.
            vc.tabBarItem.isEnabled = !vc.tabBarItem.isEnabled 
            vc.tabBarItem.isEnabled = !vc.tabBarItem.isEnabled  //This duplicate is not a mistake!
        }
    }
}

In my opinion, this is a bug of iOS and you should better write a bug report.


By the way, you cannot use Xcode 9.4.1 to build an app to submit to App Store. Better upgrade to Xcode 10.1 (or later) soon.