代码之家  ›  专栏  ›  技术社区  ›  William Hu

Facebook uiAlertView问题

  •  0
  • William Hu  · 技术社区  · 15 年前

    我在应用程序上使用了Facebook SDK。当我按下“添加订阅源到你的墙上”后,警报会弹出“是”或“否”。如果我选择“是”,FBstreamDialoy就会闪开。

    首先,单击“将源添加到墙”按钮调用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];
    
    2 回复  |  直到 11 年前
        1
  •  1
  •   Arun Chandran    14 年前

    延迟0.1秒后调用它[自我执行选择器:@selector(fbbuttonclick)withobject:nil after delay:0.10];

        2
  •  0
  •   Roland Keesom    13 年前

    问题是你在听:

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

    应该是:

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

    因为在 clickedButtonAtIndex 函数视图未关闭,这可能导致问题。

    编辑: 要使其在iOS 4中工作,请将您的Facebook登录调用添加到方法中,并调用diddiswithbuttonIndex中的以下函数:

    [自我执行selectornmainthread:@selector(facebookopenaction)withobject:nil waituntildone:no];