简体   繁体   English

Facebook未登录我的应用

[英]Facebook is not login in my app

Hi i am using like feature in my app on Xcode 4.6 in Xib files but on clicking facebook is not login. 嗨,我在Xib文件中的Xcode 4.6上的我的应用程序中使用了类似功能,但是单击Facebook时未登录。 While on the other side it is login when i do in another app in Story Board. 另一方面,当我在Story Board中的另一个应用程序中执行操作时,这是登录名。 Please guide me if any one knows about it. 如果有人知道,请指导我。

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

Your code seems to be OK, and you're using code of FacebookLikeView , when I tried to implement the same in my application it won't show up the login because I forgot to bind FacebookLikeView with IB. 您的代码似乎还可以,并且您正在使用FacebookLikeView的代码,当我尝试在应用程序中实现相同代码时,由于我忘记了将IB绑定FacebookLikeView因此不会显示登录信息 Another problem that also happened to me was, You may need to cut _facebook = [[Facebook alloc] initWithAppId:@"129649123867187" andDelegate:self]; 我还遇到的另一个问题是,您可能需要剪切_facebook = [[Facebook alloc] initWithAppId:@"129649123867187" andDelegate:self]; line from init method and put it into viewDidLoad like below, because it won't called up in my case! init方法行并将其放入如下所示的viewDidLoad中,因为在我的情况下不会调用它!

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

I believe that you don't forget to set delegate for FBConnect , FacebookLikeViewDelegate and FBSessionDelegate 我相信您不会忘记为FBConnectFacebookLikeViewDelegateFBSessionDelegate设置委托

If you still can't solve out the problem, then it may be with your Facebook App ID do try to use the default app id given there in source code, it should work! 如果您仍然无法解决问题,则可能是因为您的Facebook App ID尝试使用源代码中提供的默认Facebook App ID ,它应该可以工作!

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

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