gpt4 book ai didi

ios - 在 presentViewController 不起作用后调用 pushViewController

转载 作者:可可西里 更新时间:2023-11-01 05:40:39 33 4
gpt4 key购买 nike

我正在这样展示我的 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/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com