Facebook Feed Dialog中的神秘放大镜

时间:2014-04-07 09:17:01

标签: ios facebook cocoapods

我通过带有Podfile的CocoaPods安装了Facebook iOS SDK

platform :ios, '6.0'
pod 'Facebook-iOS-SDK'

屏幕截图如下:

Weird magnifying glass

当我使用以下代码(在按钮的IBAction中)尝试与Facebook共享消息时,模拟器的右上角会出现放大镜(我按照Getting Started上的教程进行操作):

FBShareDialogParams *params = [[FBShareDialogParams alloc] init];
params.link = [NSURL URLWithString:@"http://www.google.com"];
params.name = @"Google";
params.caption = @"Google is Great";
params.picture = [NSURL URLWithString:@"http://i.imgur.com/g3Qc1HN.png"];
params.description = @"Google is a good search engine";

if([FBDialogs canPresentShareDialogWithParams:params]) {
    // Present share dialog (requires Facebook App v6.0+ installed)
    [FBDialogs presentShareDialogWithLink:params.link
                                     name:params.name
                                  caption:params.caption
                              description:params.description
                                  picture:params.picture
                              clientState:nil
                                  handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
         if(error) {
             NSLog(@"%@", [NSString stringWithFormat:@"Error publishing story: %@", error.description]);
         } else {
             NSLog(@"result %@", results);
         }
     }];
} else {
    // Present feed dialog
    NSMutableDictionary *params1 = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"Google", @"name",
                                   @"Google is Great", @"caption",
                                   @"Google is a good search engine", @"description",
                                   @"http://www.google.com", @"link",
                                   @"http://i.imgur.com/g3Qc1HN.png", @"picture",
                                   nil];

    [FBWebDialogs presentFeedDialogModallyWithSession:nil
                                           parameters:params1
                                              handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
                                                  if (error) {
                                                      // An error occurred, we need to handle the error
                                                      // See: https://developers.facebook.com/docs/ios/errors
                                                      NSLog(@"%@",[NSString stringWithFormat:@"Error publishing story: %@", error.description]);
                                                  } else {
                                                      if (result == FBWebDialogResultDialogNotCompleted) {
                                                          // User cancelled.
                                                          NSLog(@"User cancelled.");
                                                      } else {
                                                          // Handle the publish feed callback
                                                          NSDictionary *urlParams = [self parseURLParams:[resultURL query]];

                                                          if (![urlParams valueForKey:@"post_id"]) {
                                                              // User cancelled.
                                                              NSLog(@"User cancelled.");

                                                          } else {
                                                              // User clicked the Share button
                                                              NSString *result = [NSString stringWithFormat: @"Posted story, id: %@", [urlParams valueForKey:@"post_id"]];
                                                              NSLog(@"result %@", result);
                                                          }
                                                      }
                                                  }
                                              }];
}

这是在课程结束时,@end之前:

// A function for parsing URL parameters returned by the Feed Dialog.
- (NSDictionary*)parseURLParams:(NSString *)query {
    NSArray *pairs = [query componentsSeparatedByString:@"&"];
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    for (NSString *pair in pairs) {
        NSArray *kv = [pair componentsSeparatedByString:@"="];
        NSString *val =
        [kv[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        params[kv[0]] = val;
    }
    return params;
}

使用Feed对话框,因为模拟器没有Facebook App v6.0 +

放大镜完全阻挡“共享”按钮。我该如何删除它?

注意:安装的版本是v3.13.0(在撰写本文时,官方最新版本为3.13.1)。

注意:使用的iOS是6.0,7.0,7.1。

1 个答案:

答案 0 :(得分:0)

此问题已由Facebook在服务器端解决。放大镜已被移除。

无需更新Facebook SDK。