我正在这样展示我的 View Controller -
[self.navigationController presentViewController:self.thingContainerViewController animated:YES completion:nil]; //self.navigationController not nil here
这显示了一个 UITableView。我想从这里在导航堆栈上推送一个 VC。但是此时 self.navigationController 为 nil。知道如何进行这项工作吗?
[self.navigationController pushViewController:otherContainer animated:YES]; //self.navigationController is nil at this point
最佳答案
您需要将要呈现的 View Controller 包装在导航 Controller 中,以便能够使用 push 和 pop 方法。
第一步:
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.thingContainerViewController];
然后:
[self.navigationController presentViewController:navigationController animated:YES completion:nil];
如果你这样做,你的代码就会工作。
关于ios - 在 presentViewController 不起作用后调用 pushViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31599482/