使用 initWithNibName 绝对不会改变任何东西

发布于 2024-10-04 05:37:10 字数 917 浏览 3 评论 0原文

我正在尝试使用不同的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

如何视而不见 2024-10-11 05:37:10

您是否尝试使用 nil 而不是 [NSBundle mainBundle] ?

WorkflowViewController *workflowViewController = [[WorkflowViewController alloc] initWithNibName:@"Workflow" bundle:nil];
[self.navigationController pushViewController:workflowViewController
                                 animated:YES];
[workflowViewController release];

did you try to use nil instead of [NSBundle mainBundle] ?

WorkflowViewController *workflowViewController = [[WorkflowViewController alloc] initWithNibName:@"Workflow" bundle:nil];
[self.navigationController pushViewController:workflowViewController
                                 animated:YES];
[workflowViewController release];
傲世九天 2024-10-11 05:37:10

我通过创建另一个控制器和另一个视图解决了这个问题。然后将所有东西重新连接在一起。看起来视图已绑定到控制器,没有任何东西可以改变它......

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...

追星践月 2024-10-11 05:37:10

我遇到了同样的问题,结果发现我的“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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文