-3

Normally,tap back button would take me to previous view controller, but I want to go to some other view controller when I tap back button .so this is what I do:

- (void)viewWillDisappear:(BOOL)animated
{
    [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:anyPreviousIndex] animated:YES];
    [super viewWillDisappear:animated];
}

But it wouldn't work. Someone got any idea about it? I appreciate for any suggestion!

4

2 に答える 2

0

この男を試してみてください

-(void) viewWillDisappear:(BOOL)animated {

    if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {

        NSLog(@"Back Pressed");

    }
    [super viewWillDisappear:animated];
}

また

-(void) viewWillDisappear:(BOOL)animated {


    if ([self.navigationController.viewControllers containsObject:self] == NO) {

        NSLog(@"Back Pressed");

    }

    [super viewWillDisappear:animated];
}
于 2014-08-29T09:51:58.180 に答える