gpt4 book ai didi

ios - 如何以编程方式打开 UINavigationController

转载 作者:行者123 更新时间:2023-11-29 01:12:42 24 4
gpt4 key购买 nike

我正在尝试以编程方式打开 UINavigationController。这是我的代码:

UIViewController *vc = [[UIStoryboard storyboardWithName:@"Storyboard"
bundle:nil] instantiateViewControllerWithIdentifier:@"ViewControllerID"];
UINavigationController *nc = [[UINavigationController alloc]
initWithRootViewController:vc];
nc.modalTransitionStyle = UIModalPresentationNone;
[self presentViewController:nc animated:YES completion:NULL];

我不断收到以下错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'

最佳答案

你是完全正确的,但不是展示,只是插入你的导航 Controller 。

例如

UIViewController *vc = [[UIStoryboard storyboardWithName:@"Storyboard"
bundle:nil] instantiateViewControllerWithIdentifier:@"ViewControllerID"];
UINavigationController *nc = [[UINavigationController alloc]
initWithRootViewController:vc];
[self pushViewController:nc animated:YES];

关于ios - 如何以编程方式打开 UINavigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35566605/

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