Created
March 13, 2014 09:47
-
-
Save keicoder/9525267 to your computer and use it in GitHub Desktop.
objective-c : launch with Xib for iPhone and iPad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//launch with Xib for iPhone and iPad | |
//ex 1. | |
//DLAppDelegate.h | |
@class DLViewController; | |
@interface DLAppDelegate : UIResponder <UIApplicationDelegate> | |
@property (strong, nonatomic) DLViewController *viewController; | |
@end | |
//DLAppDelegate.m | |
@implementation DLAppDelegate | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | |
// Override point for customization after application launch. | |
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { | |
self.viewController = [[DLViewController alloc] initWithNibName:@"DLViewController_iPhone" bundle:nil]; | |
} else { | |
self.viewController = [[DLViewController alloc] initWithNibName:@"DLViewController_iPad" bundle:nil]; | |
} | |
self.window.rootViewController = self.viewController; | |
[self.window makeKeyAndVisible]; | |
return YES; | |
} | |
//ex 2. | |
//AppDelegate.h | |
@class ViewController; | |
@interface AppDelegate : UIResponder <UIApplicationDelegate> | |
@property (strong, nonatomic) ViewController *viewController; | |
@end | |
//AppDelegate.m | |
#import "ViewController.h" | |
@implementation AppDelegate | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
// viewController with XIB | |
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | |
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; | |
self.window.rootViewController = self.viewController; | |
[self.window makeKeyAndVisible]; | |
return YES; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment