开发者

iPad: presentModalViewController creates a screen stack. Manipulate this stack (slide cards out from middle of deck?)

iPad: presentModalViewController creates a screen stack. Can you manipulate this stack (slide cards out from middle of deck?)

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

The above code creates a stack of screens that are 3 deep. "navigationController3" is visib开发者_如何学Gole and if it is dismissed using "[self dismissModalViewController]" then navigationController2 is visible.

While THREE is visible I want to slide TWO out of the middle of the stack/deck so that when THREE is dismissed ONE will be visible.


According to Apple doc here, the stack is a kind of double-linked list. It looks like this:

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

and

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

The problem is you cannot mess with these properties as they are readonly. The only solution I see is to dismiss navigationController2 when navigationcontroller3 is dismissed.
For instance, try this in your navigationController3 class:

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


The quick solution would be to set up a notification. Call a method in navigationController3 that sends a notification that is received by navigationController2 which calls [self dismissModalViewController]. You can do the same thing with protocol/delegate callbacks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜