应用程序窗口预计在应用程序启动结束时具有根视图控制器

我正在使用facebook iOS SDK安装教程: https : //developers.facebook.com/docs/mobile/ios/build/

第4步:添加注销到您的应用程序后,

我在5.1模拟器(xcode 4.3.2)上得到一个空白的白色屏幕,控制台显示一条消息:

应用程序窗口预计在应用程序启动结束时具有根视图控制器

编辑-1

感谢您的回应; 我在创build应用程序时select了“单一视图应用程序”模板。 在MainStoryBoard.storyboard中,我创build了一个对象,并为其分配了MyGreatIOSAppAppDelegate类。 将此对象的viewController出口拖放到View Controller。

这里是MyGreatIOSAppAppDelegate.m中的代码

#import "MyGreatIOSAppAppDelegate.h" #import "xxxViewController.h" @implementation IJSAppDelegate @synthesize window = _window; @synthesize viewController = _viewController; @synthesize facebook; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; // Add the logout button UIButton *logoutButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; logoutButton.frame = CGRectMake(40, 40, 200, 40); [logoutButton setTitle:@"Log Out" forState:UIControlStateNormal]; [logoutButton addTarget:self action:@selector(logoutButtonClicked) forControlEvents:UIControlEventTouchUpInside]; [self.viewController.view addSubview:logoutButton]; facebook = [[Facebook alloc] initWithAppId:@"id" andDelegate:self]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) { facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"]; facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"]; } if (![facebook isSessionValid]) { [facebook authorize:nil]; } return YES; } - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [facebook handleOpenURL:url]; } - (void)fbDidLogin { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"]; [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"]; [defaults synchronize]; } // Method that gets called when the logout button is pressed - (void) logoutButtonClicked:(id)sender { [facebook logout]; } - (void) fbDidLogout { // Remove saved authorization information if it exists NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if ([defaults objectForKey:@"FBAccessTokenKey"]) { [defaults removeObjectForKey:@"FBAccessTokenKey"]; [defaults removeObjectForKey:@"FBExpirationDateKey"]; [defaults synchronize]; } } @end 

检查您的应用程序委托的application:didFinishLaunchingWithOptions:中是否有以下行application:didFinishLaunchingWithOptions: method:

 self.window.rootViewController = self.viewController; 

确保你设置你的window.rootviewcontroller =你的_navigationviewcontroller。 像这样:(这一切都发生在你的AppDelegate.cs文件中)

公共部分类AppDelegate:UIApplicationDelegate {/ /级声明UIWindow _window; UINavigationController _navigationcontroller;

  // // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching (UIApplication app, NSDictionary options) { // create a new window instance based on the screen size _window = new UIWindow (UIScreen.MainScreen.Bounds); // If you have defined a view, add it here: // window.AddSubview (navigationController.View); _navigationcontroller = new UINavigationController(); _navigationcontroller.PushViewController(new SplashViewController(),false); **_window.RootViewController = _navigationcontroller;** // make the window visible _window.MakeKeyAndVisible (); return true; } } 

}