Reputation: 1981
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?
Upvotes: 0
Views: 194
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
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
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