문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top