Frage

Suppopse there are five view as A,B,C,D,E i am presenting view A to B then B to C using present view controller method. Now i want to dismiss view controller form View C to A directly. How we can do this

War es hilfreich?

Lösung

One way to do this (and perhaps the simplest) would be to use a UINavigationController and push UIViewControllers onto it.

Then you can simply call: [[self navigationController] popToRootViewControllerAnimated:YES];

Another more complex way to handle this if you really want modal view controllers would be to set up the UIViewControllers with callbacks to register that they should close immediately on next appearance.

-(void)closeImmediately
{
    mCloseImmediately = YES;
}

-(void)viewWillAppear:(BOOL)animated
{
    if(mCloseImmediately)
    {
        [self dismissModalViewControllerAnimated:NO];
        return;
    }
    // ... other normal setup code
}

Doing this in viewWillAppear and without animation means that this UIViewController never gets displayed.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top