Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
1
I've got a TabBar-application and sometimes use the following code to programmatically switch to another tab's view:

Code:
tabBarController.selectedIndex = 3;

This works for all views but one that does switch tab, but does not load the content (ie view) that is connected to that tab.

Pressing the tab works fine.

Do you have any idea where to start looking?
 
Hm, need to check the nib, if there is anything wrong there, that's my wildest guess, or check if you are trying to hide stuff in your code, which just pressing the Tabbar delegate might override, don't know, never had it, exept having issues in the nib, like simulating the tabbar etc, which screws up pixels..
 
Actually appears it had more to do where the code is placed.

What I'm trying to do is place that code inside the viewDidLoad or viewWillAppear-methods, which results in the above mentioned weirdness.

However, placing the code in the viewDidAppear-method works fine.

Apparently the view needs to be loaded completely before you can call the selectIndex on the tabbar.

Thanks for you answer anyway :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.