오류 처리2013-07-26

2280 단어
Application windows are expected to have a root view controller at the end of application launch

소스 코드:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    //-------------------------------------------------------------------------------------
    //创建基准的Controller对象
    mainViewController = [ [ MainViewController alloc ] init ];
    
    rootController = [ [ UINavigationController alloc ]
                      initWithRootViewController: mainViewController ];

    // 将母体Controller的view 追加到Window中
    [ self.window addSubview: rootController.view ];
    //-------------------------------------------------------------------------------------

    return YES;
}




모든 실행에 나타납니다








코드 수정:


에 추가
self.window.rootViewController = rootController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    //-------------------------------------------------------------------------------------
    //创建基准的Controller对象
    mainViewController = [ [ MainViewController alloc ] init ];
    
    rootController = [ [ UINavigationController alloc ]
                      initWithRootViewController: mainViewController ];
    self.window.rootViewController = rootController;
    // 将母体Controller的view 追加到Window中
    [ self.window addSubview: rootController.view ];
    //-------------------------------------------------------------------------------------

    return YES;
}

좋은 웹페이지 즐겨찾기