我在我的应用中使用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
知道为什么吗?
答案 0 :(得分: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;
}