In my app, one of the TabBar Items needs a custom icon, depending on context within the app. I'm using this code to accomplish that:
item1 = [[UITabBarItem alloc] initWithTitle:@"Jij" image:inactiveIcon selectedImage:activeIcon];
and that works just fine. As long as I don't set an icon in the Storyboard.
In my experiments, I found out that running above code from the AppDelegate's
didFinishLaunchingWithOptions
executes the code before the TabBar
even exists. At least that is what I think.
So, in order to have at least a temporary placeholder icon, I have to set it in the Storyboard. But somehow, that keeps my code from updating the image.
I even looked into subclassing the TabBarController
, just to make sure that the icon is loaded in time.
Please point me at the mistakes in my code, logic or findings.
To summarize the question:
How come I cannot change an TabBarItem
image once it is set in the Storyboard?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.