2010-06-08 82 views
0

我在我的應用程序中使用了Facebook SDK。當我按下「添加飼料到你的牆上」後,彈出「YES」或「NO」。如果我選擇「是」,FBStreamDialoy就會閃現。FaceBook UIAlertView問題

首先,點擊按鈕 「添加進你的牆」 來稱呼changeFeed:功能:

-(IBAction) changeFeed 
{ 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sporting Summer Festival Monte-Carlo" message:@"Are you attending this concert?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes",nil]; 
    [alert show]; 
    alert.tag = 1; 
    self.alertView =alert; 
    [alert release]; 

} 

然後,按 「是」 按鈕。調用此函數:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    if (buttonIndex == 0) { 
     NSLog(@"NO"); 
    } 
    else 
    { 
     NSLog(@"YES"); 
     [self showAddFeed]; 
    } 

} 

這是showAddFeed功能,這是在clickButtonAtIndex前面定義。

-(void)showAddFeed 
{ 
FBStreamDialog *dialog = [[[FBStreamDialog alloc] init] autorelease]; 
    dialog.delegate= self; 
    dialog.userMessagePrompt = @"*****"; 
     [dialog show]; 
} 

只是不能很好的工作。我不知道爲什麼?感謝您的幫助。

------------答案是--------------------------

[self performSelector:@selector(fbButtonClick) withObject:nil afterDelay:0.10]; 

回答

1

延遲0.1秒後調用它[self performSelector:@selector(fbButtonClick)withObject:nil afterDelay:0.10];

0

的問題是,你聽:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 

這應該是:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex 

因爲在clickedButtonAtIndex功能的觀點並沒有關閉,這可能會導致問題。

編輯: 使它在iOS 4的工作,你的Facebook登錄添加調用的方法,並呼籲在didDismissWithButtonIndex以下功能:

[自performSelectorOnMainThread:@selector(facebookOpenAction)withObject:無waitUntilDone:NO ]。