Kerberos
Kerberos

Reputation: 4166

iOS - Create xib in a project without xib

I have a problem with this project, It hasn't a xib file or storyboard. This project call immediately the appdelegate file into the main with this code:

int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");

and in the app delegate file we have the declaration of the view controller, instead in my project I have a xib with a view. How can I do if I want connect this in an existing project?

Upvotes: 1

Views: 522

Answers (1)

Oleg Trakhman
Oleg Trakhman

Reputation: 2082

1)Make your own xib/nib, for example MainWindow.xib. There should be three objects in MainWindow.xib, namely your "AppDelegate", UIWindow, and UINavigationViewController. Insert your Root View controller inside UINavigationController.

2) Add MainWindow to Info.plist that is to say set "Main nib file base name" to "Main Window"

3)Connect IBOutlets to your appdelegate. Example:

@interface AppDelegate : NSObject <UIApplicationDelegate>
{
    UIWindow *window;
    UINavigationController *navigationController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

@end

P.s. if you are using StoryBoards, there's simple and compact official guide: Converting to Storyboards Release Notes

Upvotes: 2

Related Questions