我已成功连接我的应用程序中的FBConnect,现在我想以这样一种方式连接:一旦用户从登录成功登录我的ViewController
应该打开。但是在哪里使用代码进入我的应用..
AppDelegate *appdelegte =(AppDelegate*)[[UIApplication sharedApplication]delegate];
[[[appdelegte navigationController] view]removeFromSuperview];
[[appdelegte window]addSubview:[[appdelegte tabBarController]view]];
[[appdelegte tabBarController]setSelectedIndex:0];
这将是我输入的代码: - bbut在Fbconnect代码中使用它的位置
- (void)session:(FBSession*)session didLogin:(FBUID)uid {
NSString* fql = [NSString stringWithFormat:
@"select uid,name from user where uid == %lld", self.usersession.uid];
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
[[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];
self.post=YES;
self.usersession =session;
NSLog(@"User with id %lld logged in.", uid);
[self getFacebookName];
}
- (void)getFacebookName {
NSString* fql = [NSString stringWithFormat:
@"select uid,name from user where uid == %lld", self.usersession.uid];
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
[[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];
self.post=YES;
}
- (void)request:(FBRequest*)request didLoad:(id)result {
if ([request.method isEqualToString:@"facebook.fql.query"]) {
NSArray* users = result;
NSDictionary* user = [users objectAtIndex:0];
NSString* name = [user objectForKey:@"name"];
self.username = name;
if (self.post) {
[self postToWall];
self.post = NO;
}
}
}
让我知道如何在从fbconnect
成功登录后进入应用程序答案 0 :(得分:0)
您应该将代码转到-session:didLogin:
转到您的主应用。登录成功时会调用此方法。如果您的视图控制器名为ViewController:
ViewController *vc = [[ViewController alloc] init];
self.window.rootViewController = vc;
如果您尚未导入ViewController.h,请将以下内容添加到文件顶部:
#import "ViewController.h"