Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacing storyboard with XIB

How can I replace storyboard with XIB?

While trying to create dynamically views and their controllers, I lost all advantages of the new storyboard. Now, when trying to remove it from the project, I created a new XIB with its own controller and replaced it in project settings:
enter image description here
Now, when trying to run the application, it crashes and the log shows me the following:

2012-04-08 14:50:16.567 Bazaart[11340:15203] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x8c15c20> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'

Here is the code of: UIRootWindow:

#import <UIKit/UIKit.h>
@interface UIRootWindow : UIViewController
@end

And its corresponding implementation:

#import "UIRootWindow.h"
@implementation UIRootWindow

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
}
- (void)viewDidUnload {
    [super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}
@end

EDIT:
I've the window as suggested by Phillip (see below). But... the way I did it is not the best, it seems. Am I doing it right?

UIRootWindow *wnd = [[UIRootWindow alloc] init];
[wnd view];
[self setWindow:wnd.window];
like image 892
UrK Avatar asked Nov 30 '25 05:11

UrK


1 Answers

Don't put anything into the Main Interface field. Instead, load your top-level controllers in the app delegate's didFinishLaunchingWithOptions: method and set the window's root controller there.

Application start-up assumes that a xib mentioned there has a File's Owner that is a UIApplication. (Older templates used to do that and some sample projects still do.)

like image 127
Phillip Mills Avatar answered Dec 01 '25 21:12

Phillip Mills