gpt4 book ai didi

ios - 无法以编程方式导航到另一个 UIViewController iOS

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

我正在尝试导航到“主页” View Controller ,为此我在 ContainerViewController 中编写了以下代码。但是一旦代码执行,应用程序就会挂起并显示 100% 的 CPU 使用率。请帮忙。

- (IBAction) home:(UIButton *)sender

{

HomeViewController *homeViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];

[self.navigationController pushViewController:homeViewController animated:YES];

//[self presentViewController:homeViewController animated:YES completion:nil];

}

最佳答案

我有一个问题想问你

1-如果您想将 SecondViewController 推送到 FirstViewController,那么您的代码就足够了

2-如果你在firstViewController中有一个containerview,你想把SecondViewcontroller的view添加到firstViewController

然后使用这段代码

UIViewController*vc1 = [[test1 alloc]initWithNibName:@"SecondViewController" bundle:nil];

//add to the container vc which is self
[self addChildViewController:vc1];

//the entry view (will be removed from it superview later by the api)
[self.view addSubview:vc1.view];

关于ios - 无法以编程方式导航到另一个 UIViewController iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28044595/

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