开发者

Using initWithNibName changes absolutely nothing

开发者 https://www.devze.com 2023-01-26 18:22 出处:网络
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.

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 *workflowViewControll开发者_如何学编程er = [[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


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];


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消