Reputation: 487
I have SingleView
application. Now I want to add a mainwindow
to my project.
How can I add the window
into my project?
Thanks in advance.
Upvotes: 1
Views: 507
Reputation: 3329
First Add Your LoginViewController
as self.window.rootViewController
such like
Add this code in your Appdelegate.h
file
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
@interface AppDelegate : NSObject <UIApplicationDelegate>
{
UIWindow *window;
}
@property (nonatomic, retain) UIWindow *window;
@end
Add this code in your Appdelegate.m
file
(Here i also added UINavigationController too)
@synthesize window=_window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
LoginViewController *loginViewController = [[LoginViewController alloc] init];
UINavigationController *loginNVController = [[UINavigationController alloc] initWithRootViewController:loginViewController];
loginNVController.navigationBarHidden = YES;
self.window.rootViewController = loginNVController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
OR Add Directly
Check this link for adding window.xib
.
Check this link
Upvotes: 1
Reputation: 920
If you have choosen single view application. You can give the xib name as per the view. That is more general in sense. If you have selected empty application then go to you xcode project and add new file. which extends from UIViewController.
AppDelegate can not be referenced in any .xib files. the main method will instantiate AppDelegate object and AppDelegate object will then instance other view controllers.
For more you can read some apple documentation.
Thanks Rinku
Upvotes: 0