在ViewController中存在问题。
在ViewController中存在问题。
此问题已有答案:
可能的重复:
我的代码有问题。
我想要去另一个视图控制器,所以这是我的代码:
- (void)reloadMyTB { TestViewController *vc = [[TestViewController alloc] init]; UINavigationController *cntrol = [[UINavigationController alloc] initWithRootViewController:vc]; [self presentModalViewController:cntrol animated:NO]; [cntrol release]; }
但它不起作用,我可以在日志中读到以下行:
Warning: Attempt to present on whose view is not in the window hierarchy!
谢谢!
admin 更改状态以发布 2023年5月24日
首先,检查你的应用程序是否实现了导航控制器,如果没有,请先实现它,然后按照以下步骤进行
并将视图与文件所有者绑定
请按以下方式重写代码
TestViewController *vc = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil]; //or write TestViewController nib Name here UINavigationController *cntrol = [[UINavigationController alloc] initWithRootViewController:vc]; [self presentModalViewController:cntrol animated:NO]; [cntrol release];