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

标签 ios

我有 A -> B ->C Controller ,与下一个委托(delegate)链接:

@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");
}

为什么在委托(delegate)回调中没有第二次调用 [ self.navigationController popViewControllerAnimated:YES ]?

最佳答案

如果你想去A:

popToRootViewControllerAnimated:

如果你有超过 3 个 View Controller A->B->C->D 并且你想从 D 转到 B,则另一种选择。

- popToViewController:animated:

引用UINavigationController Class Reference

关于ios - [ self.navigationController popViewControllerAnimated :YES ]; doesn't work in delegate callback,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13551468/

相关文章:

ios - Storyboard performSegueWithIdentifier 不工作

ios - 在 Swift 中嵌套 UIScrollView

ios - ionic/cordova 项目中的 Xcode 设备列表为空

ios - UINavigationItem 动画

ios - 使用 JAVAPNS 成功发送推送但未在客户端设备中接收

ios - 在 iOS 应用程序公开发布之前提交 Facebook 应用程序以供审核?

ios - 在特定位置截断 UILabel

ios - Firebase 通知 - 如何只向特定用户发送通知?

ios - 在 iOS 13 全屏中呈现模式

mysql - 是在 xCode 中编写应用程序还是在 PHP/mySQL 中使其成为 webApp