我在我的应用上使用了Facebook SDK。在我按下"Add feed to your wall“后,提示弹出"YES”或"NO“。如果我选择“是”,FBStreamDialoy就会闪现。
首先,点击“Add feed to your wall”按钮调用changeFeed: function:
-(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];
}
}这是在clickButtonAtIndex前面定义的showAddFeed函数。
-(void)showAddFeed
{
FBStreamDialog *dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.delegate= self;
dialog.userMessagePrompt = @"*****";
[dialog show];
}只是不能很好的工作。我也不知道原因?谢谢你的帮助。
-答案是
[self performSelector:@selector(fbButtonClick) withObject:nil afterDelay:0.10];发布于 2011-03-07 20:45:39
延迟0.1秒后调用self performSelector:@selector(fbButtonClick) withObject:nil after delay :0.10;
发布于 2012-02-07 20:44:17
问题是你听的是:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex这应该是:
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex因为在clickedButtonAtIndex函数中,视图并未关闭,这可能会导致问题。
编辑:要使其在Facebook4中工作,请将您的iOS登录调用添加到一个方法中,并在didDismissWithButtonIndex中调用以下函数:
self performSelectorOnMainThread:@selector(facebookOpenAction) withObject:无等待waitUntilDone:否;
https://stackoverflow.com/questions/2995771
复制相似问题