I have a storyboard enabled App with a TabBarController where I have added viewcontrollers through the interface builder.
Then I followed the iDevReceipes post to add a custom button in the center, which hide my third or center tab bar item with a custom button.
I’m not able to make the TabBarController select the middle tab when a user clicks the button. I wired the button with a selector and within the method I added a code which was supposedly a solution which worked for many on Stack Overflow i.e self.tabBarController.SelectedIndex = 2; this was called in viewWillAppear
This is somehow not working and selecting the correct tab. I had a NSLog inside the method of the button and I found out the button works but the tab is not getting selected.
The tabbarcontroller has a class with nothing inside this.
You have the right idea, but you need to use a setter method and not set the property directly; this is one instance where it does make a difference. Also, I may be misunderstanding you, but you need to call this code in the selector for the button, not in the
viewWillAppearmethod. Here’s the code you’ll use to select the middle index.