2011-07-06 34 views
4

iPad:presentModalViewController創建一個屏幕堆棧。你可以(從甲板中滑座牌開出?)操縱這個棧iPad:presentModalViewController創建一個屏幕堆棧。操作這個堆棧(從卡片中間滑出卡片)

 
[self presentModalViewController:navigationController1 animated:NO]; 
[self presentModalViewController:navigationController2 animated:NO]; 
[self presentModalViewController:navigationController3 animated:NO]; 

上面的代碼創建了屏幕的堆棧3個深。 「navigationController3」是可見的,如果使用「[self dismissModalViewController]」將其解除,那麼navigationController2是可見的。

雖然THREE可見,但我想將TWO從堆棧/卡組的中間滑出,以便當THREE被解散時,一個可見。

回答

0

快速解決方案是設置通知。調用navigationController3中的一個方法,該方法發送由navigationController2接收的調用[self dismissModalViewController]的通知。你可以用協議/委託回調來做同樣的事情。

1

根據Apple文檔here,堆棧是一種雙鏈表。它看起來像這樣:

self.modalViewcontroller     --> navigationController1 
navigationController1.modalViewController --> navigationController2   
navigationController2.modalViewController --> navigationController3 

navigationController1.parentViewcontroller--> self 
    navigationController2.parentViewcontroller--> navigationController1   
    navigationController3.parentViewcontroller--> navigationController2 

問題是你不能亂用這些特性,因爲它們是隻讀的。 我看到的唯一解決方案是當navigationcontroller3被解僱時關閉navigationController2。
例如,在您的navigationController3類中試試這個:

-(void)viewWillDisappear:(BOOL)animated 
{ 
    [super viewWillDisappear:animated]; 
    self.parentviewcontroller. //navigationController2 
      parentviewcontroller. //navigationController1 
       dismissModalViewControllerAnimated:NO]; 
}