2014-05-05 23 views

回答

1

首先添加您的LoginViewControllerself.window.rootViewController諸如此類

Appdelegate.h文件中添加以下代碼

#import <UIKit/UIKit.h> 
#import "AppDelegate.h" 
@interface AppDelegate : NSObject <UIApplicationDelegate> 

{ 
    UIWindow *window; 
} 

@property (nonatomic, retain) UIWindow *window; 

@end 

Appdelegate.m文件 (在這裏,我還加的UINavigationController太)

添加該代碼
@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; 
} 

或直接添加

選擇此鏈接添加window.xibCheck this link

0

如果您已經選擇單一視圖的應用程序。您可以根據視圖提供xib名稱。這在意義上更一般。如果您選擇了空白的應用程序,那麼請轉到您的xcode項目並添加新文件。它從UIViewController擴展。

的AppDelegate不能以任何的.xib文件中被引用。主要方法將實例化AppDelegate對象,然後AppDelegate對象將實例化其他視圖控制器。

欲瞭解更多,你可以閱讀一些蘋果文檔。

謝謝 Rinku

+0

https://www.youtube.com/watch?v=PpB-3TwJvQE&list=LLe3XfMWEoL1QSykSSxRCLTg&index=3 –