2010-06-08 81 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 ]。