Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.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
Ios 很奇怪的警告_Ios_Facebook_Uiapplicationdelegate - Fatal编程技术网

Ios 很奇怪的警告

Ios 很奇怪的警告,ios,facebook,uiapplicationdelegate,Ios,Facebook,Uiapplicationdelegate,我目前正在我的移动应用程序中尝试Facebook的单点登录功能。到目前为止,当我测试我的应用程序时,我可以进入Facebook的Auth对话框。但当我在授权应用程序时单击OK按钮时,我的视图会显示一个黑屏。我想知道这是否是因为rootViewController的分配 在我的FbSSOTrialDelegate.m中的这行代码中 #import "FbSSOTrialAppDelegate.h" @implementation FbSSOTrialAppDelegate @synthesiz

我目前正在我的移动应用程序中尝试Facebook的单点登录功能。到目前为止,当我测试我的应用程序时,我可以进入Facebook的Auth对话框。但当我在授权应用程序时单击OK按钮时,我的视图会显示一个黑屏。我想知道这是否是因为rootViewController的分配

在我的FbSSOTrialDelegate.m中的这行代码中

#import "FbSSOTrialAppDelegate.h"

@implementation FbSSOTrialAppDelegate

@synthesize window = _window;
@synthesize facebook = _facebook;
@synthesize FbSSOTrialVC = _FbSSOTrialVC;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    NSString *FbAppId = @"MY_APP_ID";

    self.window.rootViewController = self.FbSSOTrialVC;
    [self.window makeKeyAndVisible];

    self.facebook = [[Facebook alloc] initWithAppId:FbAppId andDelegate:self];

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) {
        self.facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
        self.facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
    }

    if (![self.facebook isSessionValid]) {
        [self.facebook authorize:nil];
    }

    return YES;
}
self.window.rootViewController=self.fbsortrialvc

我从“FbSSOTrialViewController*”中收到一条警告,指出分配给“UIViewController*”的指针类型不兼容,我的控制台中也有此日志:

2012-07-09 11:17:04.798 FbSSOTrial[976:f803]应用程序窗口预计在应用程序启动结束时会有一个根视图控制器

我说这很奇怪,因为我确信FbSSOTrialVC是UIViewController的一个子类

请告诉我为什么会发生这种情况。下面是FbSSOTrialViewController.h的其他代码

#import <UIKit/UIKit.h>

@interface FbSSOTrialViewController : UIViewController

@end

根据我们的讨论,我们决定在应用程序启动期间没有正确实例化视图控制器。我们确定感兴趣的ViewController来自故事板,因此建议的代码更改如下:

// remove this
// self.window.rootViewController = self.FbSSOTrialVC;

// and replace it with:
self.FbSSOTrialVC = [self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"Fb SSO Trial VC"];
self.window.rootViewController = self.FbSSOTrialVC;

请注意,这要求在情节提要中,感兴趣的ViewController的标识符应具有Fb SSO试用VC,并根据需要进行更改。

您确定FbSSOTrialViewController确实扩展了UIViewController吗?好的,接下来是一个可能会引起注意的挑剔细节;注意星号。。。在错误消息中,FbSSOTrialViewController中可疑地缺少该文件:从FbSSOTrialViewController分配给“UIViewController*”。我想知道这是否是一个错误,或者如果你认为没有一个实际的指针,那就是错误所在。。。接下来,我们将询问self.fbsortrialvc是如何初始化的。我想这就是你的问题所在。它看起来像是设置为类对象,而不是指向实例的指针。对不起,兄弟,我再次检查了警告,FbSSOTrialVC上有星号。忘了包括它,已经编辑了帖子。你在fbsotrialdelegate.m中导入了fbsotrialviewcontroller.h吗?我添加了一个,它解决了上述代码行中的警告问题。然而,我的控制台仍然和我在这篇文章中提到的一样。
// remove this
// self.window.rootViewController = self.FbSSOTrialVC;

// and replace it with:
self.FbSSOTrialVC = [self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"Fb SSO Trial VC"];
self.window.rootViewController = self.FbSSOTrialVC;