[self.navigationController popViewControllerAnimated:YES];在委托回调中不起作用

时间:2012-11-25 13:28:28

标签: ios

我有A - > B - > C控制器,与下一个代表链接:

@protocol ViewControllerDelegate <NSObject>

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

@end

在C中我打电话:

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

比我进入B:

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

为什么在委托回调中第二次不调用[self.navigationController popViewControllerAnimated:YES]?

1 个答案:

答案 0 :(得分:1)

如果你想去A:

popToRootViewControllerAnimated:

如果您有超过3个视图控制器A-> B-&gt; C-&gt; D并且您想要从D到B,则可以选择其他选项。

- popToViewController:animated:

请参阅UINavigationController Class Reference