Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 应用程序窗口应在应用程序启动结束时具有根视图控制器_Iphone_Ios_Facebook - Fatal编程技术网

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

Iphone 应用程序窗口应在应用程序启动结束时具有根视图控制器,iphone,ios,facebook,Iphone,Ios,Facebook,我正在使用facebook iOS SDK安装教程: 在步骤4:将注销添加到应用程序后 我在5.1模拟器(xcode 4.3.2)上看到一个空白的白色屏幕,控制台显示一条消息: 应用程序窗口应在应用程序启动结束时具有根视图控制器 编辑-1 感谢您的回复; 我在创建应用程序时选择了“单视图应用程序”模板。在MainStoryBoard.storyboard中,我创建了一个对象,并为其分配了MyGreatiosAppDelegate类。将此对象的viewController出口拖放到视图控制器 下面

我正在使用facebook iOS SDK安装教程:

在步骤4:将注销添加到应用程序后

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

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

编辑-1

感谢您的回复; 我在创建应用程序时选择了“单视图应用程序”模板。在MainStoryBoard.storyboard中,我创建了一个对象,并为其分配了MyGreatiosAppDelegate类。将此对象的viewController出口拖放到视图控制器

下面是mygreatiosappdelegate.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

检查应用程序代理的
应用程序中是否有以下行:didFinishLaunchingWithOptions:
方法:

self.window.rootViewController = self.viewController;

确保设置了window.rootviewcontroller=您的_navigationviewcontroller。如下:(这些都发生在AppDelegate.cs文件中)

公共部分类AppDelegate:UIApplicationDelegate { //类级声明 UIWindow\u窗口; UINavigationController\u导航控制器

    //
    // 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;
    }
}

}

你能发布你的
mygreatiosappdelegate.m
吗。你可以编辑这篇文章就可以了。你解决这个问题了吗?我也有同样的问题,如果你这样做了,如果你发布这个解决方案就好了。你使用的是哪个版本的Xcode?不同的版本有不同的项目模板。你可以发布
main.c
和你的应用程序代理标题吗?以及故事板中的对象列表和
Info.plist
?Dupes:可能还有moreHi@jonkroll,我正在使用self.window.rootViewController=self.viewController;我不确定,但我在MainstryBoard.storyboard中缺少了一些内容。我创建了一个对象,并为其分配了MyGreatiosAppDelegate类。将此对象的viewController出口拖放到View Controller.jQueryEnthusist,是否获得查询的最终解决方案?