Failed to load thread called "TwitterDrilldownView"

-[UIViewController _loadViewFromNibNamed:bundle:] was unable to load a nib named "TwitterDrilldownView"

      

I am getting the above error when I push a new ViewController onto the navigation stack. This is the push code,

[self.navigationController pushViewController:[[[TwitterDrilldownViewController alloc] initWithTwitterAnnotation:temp] autorelease] animated:YES];

Basically I just push the newly allocated and initialized view onto the stack. The init method for the ViewController is

- (id)initWithTwitterAnnotation:(TwitterInfo *)aPOI {  
  if(self = [super init]) {
    poi = aPOI;
  }

  return self;
}

      

As you can see, I am not using nib method initialization and there is no nib file named TwitterDrilldownView in my project.

I had a nib file before I created a TwitterDrilldownViewController called TwitterDrillDownView, but I used it to check the layout and, again, never used it. When I created TwitterDrilldownViewController, there was TwitterDrillDownView.nib in the project and it was after this step that I removed the thread.

The only reason for this problem that I can think of is that Xcode has somehow created a dependency on the nib file because the nib file and the view controller are named the same (TwitterDrilldownView.nib, TwitterDrilldownViewController.m) as if this was trying to be helpful but ended up screwing up my project.

I tried deleting and recreating the view controller in the hopes that any references would be destroyed and would remove any reference to nib files in the project, to no avail.

Anyone can get any experience with this problem or know about a possible solution?

+2


a source to share


2 answers


This also happened to me after deleting the XIB file from my project. However, I was a little worried and was able to fix the problem.

The key point is that Xcode seems to keep some kind of link somewhere when you create XIBs and outputs / actions inside them, and manually deleting the XIB file just makes orphans those links . Deleting these connections one by one using the Interface Builder (UB) and the XIB seems to be canceling them correctly.

The solution is pretty clear:



  • Re-create the XIB file with the same name and similar construction (including the outputs and actions you had before). (Note: If you can't remember how to rebuild the XIB outputs and actions, just re-create the XIB file with the same name and skip to my "if it still failing" note below.)
  • Manually, one by one, remove all outputs and activities in your XIB using the Interface Builder (IB).
  • Restore the application; if it works now, you can remove the XIB.

( Note: if it still doesn't work , you will probably have a different error. If the error is about keeping the key value, then it will display the method in error - and that method is yours. Make sure you recreate the named socket / action in IB and removed it manually with IB. This seems to override the invocation reference in Xcode / your build environment.)

Happy hunting!

+2


a source


UIViewController must be initialized using the method initWithNibName:bundle:

. Its description states:

This is the designated initializer for this class.

If you specify nil for nibName and do not override the loadView method in your normal subclass, the view controller's default behavior is to look for a nib file whose name (without the .nib extension) matches the name of your view controller class. If it finds one, the class name becomes the value of the nibName property, which results in the corresponding nib file that is associated with that view controller.



So if you are not loading the view controller from the nib file, make sure you override the method loadView

and set the controller property in it view

.
Hope it helps.

+1


a source







All Articles