0

I have a UIViewController subclass which I am instantiating and trying to push on to the navigationController like so :

MenuVC *menuVC = [[MenuVC alloc] init]; [self.navigationController pushViewController:menuVC animated:YES]; 

I don't have a nib file associated with this class and so just doing a simple ..alloc] init] instead of initWithNib:bundle:.

I am still getting a crash on the pushViewController call and the trace says this

reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "MenuVC" nib but the view outlet was not set.' 

I don't see why this could be happening. I have other view controller which loads fine with the same method.

6
  • Does MenuVC override the init method by chance? Commented Feb 27, 2013 at 21:34
  • @Fraggle no it doesn't Commented Feb 27, 2013 at 21:44
  • 1
    Could there be an old MenuVC.nib in the app bundle? Commented Feb 27, 2013 at 22:11
  • Are you using a Story board for this? Commented Feb 27, 2013 at 23:33
  • @Fraggle no. I am not using Storyboard Commented Feb 28, 2013 at 22:35

3 Answers 3

2

I think I found the answer to this in Apple's Docs :

A view controller has an associated nib file if the nibName property returns a non-nil value, which occurs if the view controller was instantiated from a storyboard, if you explicitly assigned it a nib file using the initWithNibName:bundle: method, or if iOS finds a nib file in the app bundle with a name based on the view controller’s class name.

So, this means the OS actually tries to load the nib if it finds one. I did have a nib in my bundle with same name as VC but had not associated it's File Owner.

Sign up to request clarification or add additional context in comments.

1 Comment

In my case nib file was left in a build folder, even though I have deleted corresponding xib file from the project. Fresh and clean build solved the problem: Cmd+Shift+K, Cmd+R.
1

The real problem is that the Viewcontroller have a view that comes in default and somehow that connection of IB to class view->view went missing and hence the error

Comments

0

This might not be an "answer" but this was resolved. I just removed the whole file and added a new file with a different name and it worked.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.