2013-03-04 41 views
2

嗨,我在Xib 4.6在Xib文件中的应用程序中使用像我的应用程序中的功能,但点击Facebook是不是登录。而另一方面,当我在故事板中的另一个应用程序中进行登录时,则是登录。如果有人知道,请指导我。Facebook是不是在我的应用程序登录

- (id)initWithCoder:(NSCoder *)aDecoder { 
    if (self = [super initWithCoder:aDecoder]) { 
     _facebook = [[Facebook alloc] initWithAppId:@"129649123867187" andDelegate:self]; 
    } 
    return self; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
    self.facebookLikeView.href = [NSURL URLWithString:@"http://sis.uol.edu.pk/sis/MainForms/login.aspx"]; 
    self.facebookLikeView.layout = @"button_count"; 
    self.facebookLikeView.showFaces = NO; 
    // self.facebookLikeView.alpha = 1; 
    [self.facebookLikeView load]; 
    facebookLikeView.delegate = self; 
} 

#pragma mark FBSessionDelegate methods 

- (void)fbDidLogin { 
    self.facebookLikeView.alpha = 1; 
    [self.facebookLikeView load]; 
} 

- (void)fbDidLogout { 
    self.facebookLikeView.alpha = 1; 
    [self.facebookLikeView load]; 
} 

#pragma mark FacebookLikeViewDelegate methods 

- (void)facebookLikeViewRequiresLogin:(FacebookLikeView *)aFacebookLikeView { 
    [_facebook authorize:[NSArray array]]; 
} 

- (void)facebookLikeViewDidRender:(FacebookLikeView *)aFacebookLikeView { 
    [UIView beginAnimations:@"" context:nil]; 
    [UIView setAnimationDelay:0.5]; 
    self.facebookLikeView.alpha = 1; 
    [UIView commitAnimations]; 
} 

- (void)facebookLikeViewDidLike:(FacebookLikeView *)aFacebookLikeView { 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Liked" 
                message:@"You liked my app. Thanks!" 
                delegate:self 
              cancelButtonTitle:@"OK" 
              otherButtonTitles:nil] ; 
    [alert show]; 
} 

- (void)facebookLikeViewDidUnlike:(FacebookLikeView *)aFacebookLikeView { 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Unliked" 
                message:@"You unliked my app ." 
                delegate:self 
              cancelButtonTitle:@"OK" 
              otherButtonTitles:nil] ; 
    [alert show]; 
} 
+0

请张贴一些代码.... – 2013-03-04 09:34:42

+0

知道你可以看到它 – 2013-03-04 09:44:07

+0

你检查FBSession.activeSession.isOpen fbuser是否登录 – 2013-03-04 09:53:36

回答

0

您的代码似乎是确定,你正在使用的FacebookLikeView代码,当我试图实现我的应用程序同样也不会出现登录因为我忘了绑定FacebookLikeView与IB。另一个问题也发生在我身上,你可能需要从init方法中删除_facebook = [[Facebook alloc] initWithAppId:@"129649123867187" andDelegate:self]; 行,并将其放入如下所示的viewDidLoad,因为它不会在我的情况下调用!

if(!_facebook) 
{ 
    _facebook = [[Facebook alloc] initWithAppId:@"129649123867187" andDelegate:self]; 
} 

我相信,你不要忘记设置委托FBConnectFacebookLikeViewDelegateFBSessionDelegate

如果仍然不能解决出了问题,那么它可能是您Facebook App ID也尝试使用在源代码中给出的默认应用程序ID,它应该工作!

相关问题