1

I am having a strange issue when attempting to dynamically load a view.

The error I get is as follows:

* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'ItemView'' * First throw call stack:

The strange thing is, it appears to happen at random - sometimes it works, sometimes it bails out on me.

I create the item as follows:

CGRect  viewRect = CGRectMake(2.5, 2.5, 100, 80);
ItemView *item = [[ItemView alloc] initWithFrame:viewRect];

and the constructor is as follows:

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        NSArray *subviewArray = [[NSBundle mainBundle] loadNibNamed:@"ItemView" owner:self options:nil];
        rootView = [subviewArray objectAtIndex:0];
        [itemButton addTarget:self action:@selector(itemButtonPressed) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:rootView];
    }
    return self;
}

Does anyone know what would cause this?

Mick Walker
  • 3,862
  • 6
  • 47
  • 72
  • some answers here usually work: http://stackoverflow.com/questions/4155292/could-not-load-nib-in-bundle-on-iphone-device – Rok Jarc Nov 08 '12 at 23:12

0 Answers0