我正在像这样展示我的 View Controller -
[self.navigationController presentViewController:self.thingContainerViewController animated:YES completion:nil]; //self.navigationController not nil here
这显示了一个 UITableView。我想从这里在导航堆栈上推送一个 VC。但此时 self.navigationController 为零。知道如何进行这项工作吗?
[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/