Im going to try to explain my problem as good as possible.
When my application starts it checks this in the appdelegate class:
if([[NSUserDefaults standardUserDefaults] boolForKey:@"checkboxClicked"]){
tabBarItem3.image = [UIImage imageNamed:@"lock-open"];
tabBarItem3.title = @"Logga ut";
}
else{
tabBarItem3.title = @"Logga In";
tabBarItem3.image = [UIImage imageNamed:@"lock.png"];
}
essentially it is deciding if the image should be an lock or unlocked with the corresponding titles. Now it all works fine and the image is what it should be showed.
Scenario 1) The user starts the app and the image starts with the "lock-open" image. Later the user goes to the logout page and loggs off the user. When the UITabBarItem that should change it's image is clicked after that, it still shows the image "lock-open". HOWEVER when the user clicks on another UITabBarItem then the correct image is being shown. NOTE the title is always set correct. Just the image thats doing the weird stuff.
Scenario 2) Just vise versa user starts as logged off etc..
This is the code i use to change the image:
UITabBarItem *item = self.tabBarController.tabBar.items[2];
item.image = [UIImage imageNamed:@"lock"];
item.title = @"Logga in";