PDA

View Full Version : Tabbar selectedindex only switching tab, but not loading view




Danneman101
Feb 13, 2012, 09:48 PM
I've got a TabBar-application and sometimes use the following code to programmatically switch to another tab's view:


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?



jnoxx
Feb 14, 2012, 02:28 AM
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..

Danneman101
Feb 14, 2012, 05:59 PM
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 :)