0
votes

Hi all I'm trying to display a custom view in my ViewController achieved through the use of a XIB file.

In my custom view class I have added this and given the name of the class and the View XIB CustomView to this ViewController via the storyboard Contina but my app to crash ...

the app does not crash when I delete

  [[NSBundle mainBundle] loadNibNamed: @ "NPUStepsView" owner: self options: nil];

I do not understand where I'm wrong ... Maybe it is not the correct method in the goalscoring stakes Xcode 6?

   -(id)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        [[NSBundle mainBundle] loadNibNamed:@"NPUStepsView" owner:self options:nil];

    }
    return self;
}
1

1 Answers

0
votes

Wherever you are creating the ViewController's instance you have to create it this way :

ViewController *vc = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];

And then you can push or present this ViewController.