Reputation: 1055
When I call my view controller, it comes up blank and does not seem to be correctly calling the layout in my NIB. I have at least 5 other classes that respect my NIB layout just fine.
I have a class chwFinishedViewController.h
On my storyboard I have a UIViewController
that is assigned this class and given the storyboardID complete
. See the below screenshot
Here is chwFinishedViewController.m
#import "chwFinishedViewController.h"
@interface chwFinishedViewController ()
@end
@implementation chwFinishedViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Here is how I call the controller. Everything before the controller call execute properly:
if (!error) {
chwFinishedViewController *complete = [[chwFinishedViewController alloc] init];
[self.navigationController pushViewController:complete animated:YES];
}
Upvotes: 2
Views: 436
Reputation: 4097
I had a similar issue, my solution was to remove an empty loadView method that had gotten left behind in the code for the viewcontroller class.
Upvotes: 0
Reputation: 3416
you have just init the controller..
use initWithNibName instead of only init
Upvotes: 1
Reputation: 3658
Try this:
chwFinishedViewController *complete = [[chwFinishedViewController alloc] initWithNibName:@"complete" bundle:nil];
There is no relation between your xib and chwFinishedViewController constructor. You use just init
which doesn't make anything. Here's apple doc.
EDIT
You use storyboard. So try this:
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
chwFinishedViewController* complete = [storyboard instantiateViewControllerWithIdentifier:@"complete"];
Upvotes: 4
Reputation: 11197
It should be:
chwFinishedViewController *complete = [[chwFinishedViewController alloc] initWithNibName:@"complete" bundle:nil];
Hope this helps.. :)
Upvotes: 0
Reputation: 2337
Use this...
chwFinishedViewController *complete = [[chwFinishedViewController alloc] initWithNibName:@"complete" bundle:nil];
Upvotes: 0