Replacing storyboard with XIB

How can I replace storyboard with XIB?

When trying to create dynamic views and their controllers, I lost all the benefits of the new storyboard. Now, while trying to remove it from the project, I created a new XIB with my controller and replaced it in the project settings:
enter image description here
Now when you try to run the application, it crashes and the log shows me this:

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: 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 have a window suggested by Philip (see below). But ... how I did it, it's not the best. Am I doing it right?

UIRootWindow *wnd = [[UIRootWindow alloc] init];
[wnd view];
[self setWindow:wnd.window];

      

+3


source to share


2 answers


Don't put anything in the main interface box. Instead, load the top level controllers into the didFinishLaunchingWithOptions: delegate app and set the root window controller there.



When launching the application, it is assumed that the xib mentioned there has a File Owner which is UIApplication. (Old templates used for this and some sample projects still do.)

+7


source


When your application starts up, each controller in your XIB is created based on the name of the class you have installed. Then each property that you visualized visually is set using KVC. The error tells you that somewhere in this process the "view" property is incorrect.

I can think of two reasons why this might be happening:



  • You don't have a suitable set of classes for your ViewController or other object in your XIB (in the "Identity Inspector")
  • You have connected the connections incorrectly. (In the "Connection inspector")

In any case, you can quickly make customizations in your XIB by specifying where the "view" property is connected.

0


source







All Articles