繁体   English   中英

Facebook未登录我的应用

[英]Facebook is not login in my app

嗨,我在Xib文件中的Xcode 4.6上的我的应用程序中使用了类似功能,但是单击Facebook时未登录。 另一方面,当我在Story Board中的另一个应用程序中执行操作时,这是登录名。 如果有人知道,请指导我。

- (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];
}

您的代码似乎还可以,并且您正在使用FacebookLikeView的代码,当我尝试在应用程序中实现相同代码时,由于我忘记了将IB绑定FacebookLikeView因此不会显示登录信息 我还遇到的另一个问题是,您可能需要剪切_facebook = [[Facebook alloc] initWithAppId:@"129649123867187" andDelegate:self]; init方法行并将其放入如下所示的viewDidLoad中,因为在我的情况下不会调用它!

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

我相信您不会忘记为FBConnectFacebookLikeViewDelegateFBSessionDelegate设置委托

如果您仍然无法解决问题,则可能是因为您的Facebook App ID尝试使用源代码中提供的默认Facebook App ID ,它应该可以工作!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM