2

我在我的应用程序中使用 Facebook SDK 我试图将朋友选择限制为 Facebook FriendPicker 中的指定数字?我正在尝试这段代码: -

 - (void)friendPickerViewControllerSelectionDidChange:
      (FBFriendPickerViewController *)friendPicker
    {
        if ([friendPicker.selection count] >= 3) {
            UIAlertView *alertView = 
                [[UIAlertView alloc] initWithTitle:@""
                                           message:@"Max number of friends selected."
                                          delegate:self cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil];
            [alertView show];
        }
    }

    - (void)alertView:(UIAlertView *)alertView 
       clickedButtonAtIndex:(NSInteger)buttonIndex
    {
        [self dismissViewControllerAnimated:YES completion:nil];
    }

我明白了,alert但我不能拒绝FBFriendpickercontroller 任何想法为什么?

4

1 回答 1

2

知道了 !!!!!!!解决方案比我想象的要简单。你friendPickerController是一个 tableView,所以我们可以将userInteractionEnabled属性设置为NO.

- (void)friendPickerViewControllerSelectionDidChange:
(FBFriendPickerViewController *)friendPicker
{
    if ([friendPicker.selection count] <=3)
    {
        self.friendPickerController.tableView.userInteractionEnabled=YES;
    }

if ([friendPicker.selection count] >=3)
{
    UIAlertView *maxFriendsAlert =
    [[UIAlertView alloc] initWithTitle:@"Max number of friends selected."
                               message:@"no more friends can be selected,"
                              delegate:self cancelButtonTitle:@"OK"
                     otherButtonTitles:@"Buy more friends",nil];
    [maxFriendsAlert show];
    maxFriendsAlert.tag=1;

// disable friends selection
        self.friendPickerController.tableView.userInteractionEnabled=NO;
    }
于 2013-06-06T10:21:51.043 回答