3

我的fb SDK 3.2没有这个问题,但是在我升级到SDK 3.5.1之后,好友邀请者出现了一些奇怪的问题,当我选择一位朋友时,它选择了选定的一位和它下面的一位。此外,当我尝试向下滚动时,它会重新启动表格并将我带回桌面。这是我的方法:

-(IBAction)secondClick:(id)sender
{
NSDictionary *params = [[NSDictionary alloc] initWithObjectsAndKeys:nil];

[FBWebDialogs
 presentRequestsDialogModallyWithSession:nil
 message:@"Learn how to make your iOS apps social."
 title:@"Test"
 parameters:params
 handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
     if (error) {
         // Error launching the dialog or sending the request.
         NSLog(@"Error sending request.");
     } else {
         if (result == FBWebDialogResultDialogNotCompleted) {
             // User clicked the "x" icon
             NSLog(@"User canceled request.");
         } else {
             // Handle the send request callback
             NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
             if (![urlParams valueForKey:@"request"]) {
                 // User clicked the Cancel button
                 NSLog(@"User canceled request.");
             } else {
                 // User clicked the Send button
                 NSString *requestID = [urlParams valueForKey:@"request"];
                 NSLog(@"Request ID: %@", requestID);
             }
         }
     }
 }];
4

2 回答 2

1

据我所知,facebook 已经修复了这个问题,并且很快就会修复。另一种解决方案是制作您自己的自定义 UI。1. 获取好友列表 - [self startConnectionWithGraphPath:@"me/friends" 参数:params method:@"GET" completionSelector:@selector(callback)]

  1. 使用 url @“ https://graph.facebook.com/fbid/picture ”下载图片

  2. 实现一个类似于 facebook 的请求 ui 的表格视图,显示朋友列表以及他们的个人资料照片。

  3. 使用“to”参数将请求定向到选定的用户。NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"286400088", @"to", nil];

这样您就不需要显示 facebook ui 来选择朋友。尽管在用户从您的自定义 UI 中选择朋友后,该 UI 仍会出现,但这只是点击“发送”。

于 2013-05-26T00:54:57.797 回答
0

一种方法是使用 FacebookfriendPicker

https://developers.facebook.com/ios/friendpicker-ui-control/

然后将 facebook id 的结果放入 requestdialog 中,就像 Nitin 说的那样。

我将发布我的friendPicker代码:

- (IBAction)inviteFriendsClicked:(id)sender {

    // Initialize the friend picker


    FBFriendPickerViewController *friendPickerController =
    [[FBFriendPickerViewController alloc] init];
    // Set the friend picker title
    friendPickerController.title = @"Välj vänner";

    // TODO: Set up the delegate to handle picker callbacks, ex: Done/Cancel button

    // Load the friend data
    [friendPickerController loadData];
    // Show the picker modally
    [friendPickerController presentModallyFromViewController:self
                                                    animated:YES
                                                     handler:
     ^(FBViewController *sender, BOOL donePressed) {
         if(donePressed) {
             NSString *userString;
             userString = @"";
             int *counter = 0;
             for (id<FBGraphUser> user in friendPickerController.selection) {
                 NSLog(user.id);
                 NSMutableArray *userArray = [[NSMutableArray alloc] init];
                 [userArray addObject:user.id];

                 if(counter == 0){
                     userString = user.id;
                 }else{
                     userString = [NSString stringWithFormat:@"%@%@%@", userString, @",", user.id];
                 }

                 counter++;

             }

             if(counter != 0){
                 [self requestDialog: userString]; // Display the requests dialog and send the id-string with it
             }
             // NSLog(@"Selected friends: %@", friendPickerController.selection);
         }
     }];



}
于 2013-05-28T14:44:52.523 回答