我跟着从Facebook一步步的Facebook SDK教程。 我所拥有的一切,除了fbDidLogin工作获取调用...授权过程正常工作。 有人告诉我做的事:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [[controller facebook] handleOpenURL:url];
}
从fbDidLogin不叫
问题是,我不完全知道如何初始化页头我的视图控制器。 这里是我的应用程序的委托.H:
#import <UIKit/UIKit.h>
#import "FBConnect.h"
@interface fb2AppDelegate : UIResponder <UIApplicationDelegate, FBSessionDelegate> {
Facebook *facebook;
UIViewController *fb2ViewController;
}
@property (strong, nonatomic) UIWindow *window;
@property (strong,nonatomic) Facebook *facebook;
@property (nonatomic, strong) UIViewController *fb2ViewController;
@end
还有他们 :
#import "fb2AppDelegate.h"
@implementation fb2AppDelegate
@synthesize window = _window;
@synthesize facebook;
@synthesize fb2ViewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.fb2ViewController = [[UIViewController alloc] init];
facebook = [[Facebook alloc] initWithAppId:@"key_here" 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 handleOpenURL:(NSURL *)url {
return [[fb2ViewController facebook] handleOpenURL:url];
}
- (void)fbDidLogin {
NSLog(@"fbdidlogin");
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"key_here", @"app_id",
@"http://developers.facebook.com/docs/reference/dialogs/", @"link",
@"http://fbrell.com/f8.jpg", @"picture",
@"Facebook Dialogs", @"name",
@"Reference Documentation", @"caption",
@"Using Dialogs to interact with users.", @"description",
nil];
[facebook dialog:@"feed" andParams:params andDelegate:self];
}
作为视图控制器...我还没有把任何代码在其中。
那我收到的错误是:
对于“UIViewController的”没有明显的@interface声明选择的Facebook“
我究竟做错了什么?
谢谢!