简体   繁体   中英

[ self.navigationController popViewControllerAnimated:YES ]; doesn't work in delegate callback

I have A -> B - >C controllers, linked with the next delegate:

@protocol ViewControllerDelegate <NSObject>

- (void)onResult:(ControllerDelegateObject *)delegateObject;

@end

and in CI call:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    ControllerDelegateObject *object = [[ControllerDelegateObject alloc]init];
    object.model = indexPath.row;
    [delegate onResult:object];
    [ self.navigationController popViewControllerAnimated:YES ];
}

than I get in B:

-(void)onResult:(ControllerDelegateObject *)delegateObject{
    delegateObject.brand = self.chosenBrand;
    [delegate onResult:delegateObject];
    [ self.navigationController popViewControllerAnimated:YES ]; **//doesn't work**
     NSLog(@"TEST2");
}

why [ self.navigationController popViewControllerAnimated:YES ] is not called second time in the delegate callback?

If you want to go to A:

popToRootViewControllerAnimated:

Or another choice if you have more than 3 view controller A->B->C->D and you want to go from D to B.

- popToViewController:animated:

Refer to UINavigationController Class Reference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM