gpt4 book ai didi

ios - 转到 NavigationViewController 中的第二个 View Controller

转载 作者:行者123 更新时间:2023-11-29 02:17:46 24 4
gpt4 key购买 nike

我有一个 UINavigationController,它指向一个 UITableViewController(项目列表),其中有从一个单元格到另一个 UITableViewController 的转场(用于编辑项目的屏幕)。

在第一次运行应用程序时,我想跳过第一个列表并立即转到第二个屏幕,以编辑新项目。

问题是我需要传递第一个 UITableViewController,因为我需要能够返回到那个(或者有没有办法设置后退按钮指向的 Controller ? ).

我尝试过但失败的事情:

  • UINavigationControllerviewDidLoad 中设置一个 bool 值 shouldPresentNewItem(如果它设置为 true) >,显示第一个 UITableViewController,同时设置一个 bool 值,以便我可以转到编辑屏幕。

  • UINavigationControllerviewDidLoad 中使用 self.navigationController!.popToViewController(arr[index] as UIViewController, animated: true) >。这给出了一个错误,因为 self.navigationControllernil。 (我不明白为什么会这样)

如何做到这一点?

最佳答案

在导航 Controller 中设置一些 bool 值,指示您将显示编辑屏幕,并在 viewDidLoad 中仅推送没有动画的编辑 View Controller :

- (void) viewDidLoad {
[super viewDidLoad];
if (self.presentEditScreen) {
self.presentEditScreen = NO;
EditViewController *e = [[DetailViewController alloc] init];
[self pushViewController:e animated:NO];
}
}

关于ios - 转到 NavigationViewController 中的第二个 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28558712/

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