UITabBarItem Image disappearing when selected Xcode 6 Beta

I am in almost the exact same spot as you. Like you, my "unselected" tab images would show up fine, but for my selected tab images, they would not be present, and I'd get the "could not load null image..." error.

I had been assigning the images within the Storyboard IB... perhaps this is what you were doing too. Either way, within IB in the Attributes Inspector for the UITabBarItem, there are two different fields. One is under the Tab Bar Item section and it is named Selected Image. The other is under the Bar Item section and it is named Image. Just to be clear (restating my first paragraph but in terms of IB), I had "valid" images that I had saved within my .xcassets assigned to each of these Image/Selected_Image fields (each image was slightly different from the other to distinguish selection). The one that I had in my Image field would show up, and the one that I had in my Selected Image field would not.

If I put the "good" one from the Image field into the Selected Image field, I would still get the error, which didn't make sense to me.

HOWEVER, if I only put my "unselected" image into the Bar Item -> Image field and left the Tab Bar Item -> Selected Image empty, THEN the one image would get used in both places AND it would be highlighted blue when selected. This didn't give me the minor image change that I wanted (as my review of the Apple Docs for Bar Button Item indicated I should have "thicker lines" in my image for the selected item), it does at least give me an image for the selected tab. Hopefully this will help you as well.


Yjo-jo's answer is not actually a solution to this problem. It makes the tab bar use the unselected image for both normal and selected states, but does not let you use a different image for the selected state, as recommended in Apple's docs.

The bug is that the 'selected image' field for tab bar items in storyboards simply does not work, and it is still a problem as of Xcode 6.0.1 - I'm using images directly included in my app's resources rather than .xcassets and I'm experiencing the same issue. The images exist in my app's bundle, they appear in the drop-down box when editing my storyboard, and yet I get the same Could not load the "(null)" image ... error, and a blank selected image.

My solution was to add this in my tab bar item's (view controller) viewWillAppear method:

[[self tabBarItem] setSelectedImage:[UIImage imageNamed:@"(selected image file)"]];

However, when doing this, I found that the size of the image changed ever so slightly when being selected/unselected, although my images were the same size. This might be because the size of the images for tab bar items is precalculated in some specific way, and we're messing around with them just as they're about to be drawn. It's a small issue but it was enough to bug me, so in order to get them perfect I removed the previous code and added this in my tab bar controller's viewWillAppear method:

[(UITabBarItem*)[[[self tabBar] items] objectAtIndex:n] setImage:[UIImage imageNamed:@"(unselected image file)"]];
[(UITabBarItem*)[[[self tabBar] items] objectAtIndex:n] setSelectedImage:[UIImage imageNamed:@"(selected image file)"]];

Where n is the index of the tab bar item. (starting from 0)

It's ugly but it works. As far as I know, the "selected image" field just blatantly does not work in Xcode 6.