R00We
R00We

Reputation: 1981

The application does not see xib file in the bundle

I put 2 xib file in bundle. And this bundle added to the project by dragging and dropping. When [super initWithNibName: @ "RUIBrowser.bundle / RUIBrowseriPhoneView.xib" bundle: nil]; app crashes with the following error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle:' NSBundle (loaded) 'with name' RUIBrowser.bundle / RUIBrowseriPhoneView.xib'

What did I do wrong?

Added bundle

Upvotes: 0

Views: 194

Answers (3)

R00We
R00We

Reputation: 1981

I found solution. It was very simple

NSBundle *bundle = [[NSBundle alloc] initWithPath:@"RUIBrowser.bundle"];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    self = [super initWithNibName:@"RUIBrowseriPadView" bundle:bundle];
} else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
    self = [super initWithNibName:@"RUIBrowseriPhoneView" bundle:bundle];
}

Upvotes: 1

codercat
codercat

Reputation: 23301

find your nib path :

NSLog(@"nib path from bundle: %@", [self.yourNibBundle pathForResource:@"RUIBrowseriPhoneView" ofType:@"nib"]);

NSBundle *bundle = [NSBundle bundleWithPath:pathNibFile].

    UIViewController *viewController = [[yourViewController alloc] initWithNibName:@"RUIBrowseriPhoneView" bundle:bundle];

Upvotes: 0

Jayesh Thanki
Jayesh Thanki

Reputation: 2077

Use this code to initialize the nib.

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
    [super initWithNibName:@"RUIBrowseriPhoneView" bundle: nil];
}
else
{
    [super initWithNibName:@"RUIBrowseriPadView" bundle: nil];
}

Upvotes: 0

Related Questions