Tabbar selectedindex only switching tab, but not loading view

Discussion in 'iOS Programming' started by Danneman101, Feb 13, 2012.

  1. macrumors 6502

    Aug 14, 2008
    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?
  2. macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    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..
  3. thread starter macrumors 6502

    Aug 14, 2008
    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 :)

Share This Page