2013-03-04 40 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,它應該工作!

相關問題