2011-03-18 38 views
0

推出我如何去從的UITabBarController的視圖鏈接幾個模態控制器,控制器鏈模式的看法?從蘋果的視圖編程指南說,這是可行的,但是當我嘗試這樣的任務,我得到的錯誤,如何從的UITabBarController

"*Assertion failure in -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:], /SourceCache/UIKit_Sim/UIKit-1447.6.4/UIWindowController.m:186 

的類層次結構是這樣的:

的UITabBarController - > 1名兒童是一個UIViewController繼承的類名爲Tab1Controller。

Tab1Controller - >編排每個2個控制器,需要可以模態呈現的。 啓動1個模態UIViewController,當完成時(通過回調調用),解除它,然後啓動另一個模態UIViewController。

這是因爲如果有沒有結束,並開始在兩個模式控制器之間有足夠的時間。

有沒有說明如何有一個模態控制器陸續可以鏈接任何示例代碼?

回答

0

就好像兩個模態控制器之間沒有足夠的時間結束和啓動。

我想你已經擊中了要害那裏。您無法展示新的模式視圖控制器,直到前一個模式視圖控制器完成消失,並且在舊模式視圖覆蓋的視圖控制器上調用viewDidAppear:方法。

另一種選擇是提出關於第一,例如頂部的第二模態視圖

[firstModalViewController presentModalViewController:secondModalViewController animated:YES] 

然後可以調用[firstModalViewController dismissModalViewControllerAnimated:YES]駁回第二(返回到第一),或[self dismissModalViewControllerAnimated:YES]在一次消除這兩個。

0
// present modal view inside another presented modal view 

    FirstViewController *firstVC = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil]; 
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController: firstVC]; 

    // Note: you can use your viewcontroller instead self.window.rootViewController 

    [self.window.rootViewController presentViewController:navController animated:YES completion:^{ 
       //code... 
        SecondViewController *secondVC = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; 

        [navController presentViewController: secondVC animated:YES completion:nil]; 

       } 
      }]; 
+0

請格式化你的代碼(這是不可讀原樣) – kleopatra 2012-10-29 11:28:54

相關問題