gpt4 book ai didi

ios - UInavigation Controller 无法从 View Controller 切换到 tableviewcontroller

转载 作者:行者123 更新时间:2023-11-29 04:31:23 25 4
gpt4 key购买 nike

我正在尝试实现 UInavigation Controller 以将 View 从 View Controller 切换到 TableView Controller 。这是我的代码。

-(IBAction)product:(id)sender
{
Products *second=[[Products alloc]init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:second];

nav.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;

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

}

但是我不明白..我错过了什么吗..

最佳答案

首先,确保“Products”是 UIViewController 的子类。如果它是带有 .XIB 文件的 View Controller 子类,请使用“initWithNibName”实例化它,而不是 alloc & init:

Products *second = [[Products alloc] initWithNibName:"YourXibFileName.xib" bundle:[NSBundle mainBundle]];

这里的第二个问题是你无缘无故地实例化了一个 UINavigationController - 删除这一行并只保留 self.navigationController。

关于ios - UInavigation Controller 无法从 View Controller 切换到 tableviewcontroller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11698666/

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