You need to create an empty application, then press cmd + n and select coca touch > objective-c class . name the class RootViewController and leave the subclass one ( UIViewController ), then check With XIB for user interface .
Once you do this, go to the AppDelegate.m file and add the following code to - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions above: YES
self.RootViewController = [[RootViewController alloc] init]; self.navController = [[UINavigationController alloc] initWithRootViewController:self.RootViewController]; self.navController.navigationBarHidden = YES; [self.window addSubview:self.navController.view];
So now it should look like this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; self.RootViewController = [[RootViewController alloc] init]; self.navController = [[UINavigationController alloc] initWithRootViewController:self.RootViewController]; self.navController.navigationBarHidden = YES; [self.window addSubview:self.navController.view]; return YES; }
then add #import "RootViewController.h" just below #import "AppDelegate.h" . after that go to the file AppDelegate.h and add @class RootViewController; over @interface. Then add the following code under @interface AppDelegate :
@property (strong, nonatomic) RootViewController *RootViewController; @property (strong, nonatomic) UINavigationController *navController;
So, your whole AppDelegate.h should look like this:
Now that you have done all this, you can start coding your application, as usual, for the xib file! Good luck
source share