我目前正在我的移动应用程序中尝试 Facebook 的单点登录功能。到目前为止,我可以在测试我的应用程序时访问 Facebook Auth Dialog。但是当我在授权应用程序时单击“确定”按钮时,我的视图给了我一个黑屏。我想知道这是否是因为rootViewController
.
在我的这行代码中FbSSOTrialDelegate.m
self.window.rootViewController = self.FbSSOTrialVC;
我收到一条警告消息Incompatible pointer types assigning to 'UIViewController *' from 'FbSSOTrialViewController *'
,并且在我的控制台中也有此日志:
2012-07-09 11:17:04.798 FbSSOTrial[976:f803] Application windows are expected to have a root view controller at the end of application launch
我说这很奇怪,因为我确定这FbSSOTrialVC
是UIViewController
请告诉我为什么会发生这种情况。以下是 FbSSOTrialViewController.h 的其他代码
#import <UIKit/UIKit.h>
@interface FbSSOTrialViewController : UIViewController
@end
和 appDelegate
FbSSOTrialDelegate.h
#import <UIKit/UIKit.h>
#import "FBConnect.h"
@class FbSSOTrialViewController;
@interface FbSSOTrialAppDelegate : NSObject <UIApplicationDelegate, FBSessionDelegate>
{
Facebook *facebook;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet FbSSOTrialViewController *FbSSOTrialVC;
@property (nonatomic, retain) Facebook *facebook;
@end
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;
}