使用 initWithNibName 绝对不会改变任何东西
我正在尝试使用不同的 XIB 加载视图控制器,但由于某些未知的原因,它似乎根本不加载它。
通常我的代码是这样的:
WorkflowViewController *workflowViewController = [[WorkflowViewController alloc] init];
[self.navigationController pushViewController:workflowViewController
animated:YES];
[workflowViewController release];
现在我想用相同的控制器加载另一个 xib,所以我尝试了:
WorkflowViewController *workflowViewController = [[WorkflowViewController alloc] initWithNibName:@"Workflow"
bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:workflowViewController
animated:YES];
[workflowViewController release];
但它绝对没有任何作用!没有错误,没有警告,也没有加载 xib。只有一个空白界面被推送到导航控制器:/
关于为什么这样做以及如何修复它有什么想法吗?
谢谢!
- 汤姆
I'm trying to load a view controller with a different XIB, but for some unknown reasons it seems that it does not load it at all.
Usually my code is something like this:
WorkflowViewController *workflowViewController = [[WorkflowViewController alloc] init];
[self.navigationController pushViewController:workflowViewController
animated:YES];
[workflowViewController release];
And now I want to load another xib with the same controller so I tried:
WorkflowViewController *workflowViewController = [[WorkflowViewController alloc] initWithNibName:@"Workflow"
bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:workflowViewController
animated:YES];
[workflowViewController release];
But it does absolutely nothing! No errors, no warnings, and no xib loaded. Only a blank interface is pushed to the navigation controller :/
Any ideas about why it does so and how to fix it?
Thanks!
- Tom
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否尝试使用 nil 而不是 [NSBundle mainBundle] ?
did you try to use nil instead of [NSBundle mainBundle] ?
我通过创建另一个控制器和另一个视图解决了这个问题。然后将所有东西重新连接在一起。看起来视图已绑定到控制器,没有任何东西可以改变它......
I fixed the problem by creating another controller and another view. Then linked all the stuff back together. It seemed like the views was binded to the controller and nothing was able to change it...
我遇到了同样的问题,结果发现我的“WorkFlowViewController”等效项有一个空的“loadView”实现,它没有调用 super ,所以
I had the same problem and turns out my equivalent of your "WorkFlowViewController" had an empty implementation of "loadView" which wasn't calling super so that