0
我的iPhone應用程序使用UITabBarController。在第一個選項卡上,有一個scenerio,用戶可以在不更改選項卡的情況下深入兩個UIViewController。因此,屏幕流是這樣的:更改tabBarController.selectedViewController只能工作一次?
- 應用程序加載默認情況下打開第一個選項卡。
- 用戶按下一個UIButton,它將它們帶到同一選項卡中的第二個UIViewController。 :
- 從第二UIViewController中,用戶可以按下另一UIButton的他們在同一標籤
從第一UIViewController中與這些2行切換到第二時,此工作抽空三分之一的UIViewController,仍然
2ndViewController = [[SecondViewController alloc] init];
self.tabBarController.selectedViewController = 2ndViewController;
但是,當我嘗試從第二個UIViewController到第三個,它不起作用。該按鈕不做任何事情,我留在第二個UIViewController。
任何人都可以解釋這是爲什麼嗎?有沒有可以使用的解決方法?如果需要,我很樂意提供更多的代碼。
在此先感謝。
您是否嘗試過使用'selectedIndex'屬性? – gcamp 2011-04-12 19:07:43
如果我沒有弄錯,'selectedIndex'屬性會更改當前選中哪個選項卡。 tabBarController.selectedIndex = 0會將您置於第一個選項卡上,tabBarController.selectedIndex = 1會將您置於第二個選項卡等上。我想在更改UIViewControllers時保留在同一個選項卡上。 – rottendevice 2011-04-12 19:12:55