Question

Try as I might, I cannot get this to work. Here is my latest attempt. Can someone clue me in as to why this does not work?

In a method which is called by my view controller's init method:

UIImage *image = [UIImage imageNamed: @"window22.png"];
UITabBarItem *item = [[UITabBarItem alloc] initWithTitle: @"Some Title" image: image tag: 0];
self.tabBarItem = item;

All it does is put a big square where the image should be. The title in the tab bar remains the same as the view controller's title.

Everything is being instantiated programmatically here, including the tab bar controller.

Was it helpful?

Solution

According to the docs, the tabBarItem will be instantiated automatically- you don't need to create it yourself. When I've set the title and image in the tabBar for a view controller, I've used

self.tabBarItem.image = [UIImage imageNamed:imageName];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top