iOSDev
iOSDev

Reputation: 3617

Remove selection image from tabbar item on modal view dismiss

I have a tab bar based app.

I have selected/de-selected image set for every tab bar item.

On first tab I have a button that opens up modalviewcontroller.

At the time when modal view is activated, my tab bar item state is selected and has selection image.

when modal view pops up , selection image is still there. But when I dismiss modal view, I want selction image of tab bar item changed to some other image.

How do I change this image on modal view dismiss?

I'm trying to so following, but it doesn't work:

[[[self.tabBarController.tabBar items] objectAtIndex:0 ] setSelectionIndicatorImage:[UIImage imageNamed: @"abc.png"] ];

Please help.

Thanks in advance.

Upvotes: 0

Views: 598

Answers (2)

rdelmar
rdelmar

Reputation: 104082

The titles and images of the tab bar items are supposed to be set by the controller in that tab, not the tab bar controller. So, you should try changing that tab in the controller in the first tab. The method you're using is for a stand-alone tab bar, not one that's controlled by a tab bar controller. You can do that like this:

-(void)changeTitle{
    [self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"one.jpg"] withFinishedUnselectedImage:[UIImage imageNamed:@"two.jpg"]];
}

Upvotes: 1

Vishal
Vishal

Reputation: 8256

Use this may it help you:

UITabBarItem *tabBarItem1 = [[self.tabBar.tabBar items] objectAtIndex:0];
[tabBarItem1 setFinishedSelectedImage:[UIImage imageNamed:@"ab.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"abc.png"]];

Upvotes: 1

Related Questions