【问题标题】:Get Profile Photo from Facebook in iOS在 iOS 中从 Facebook 获取个人资料照片
【发布时间】:2015-10-09 11:15:37
【问题描述】:

我在我的应用中实现了 Facebook 登录并获取用户的详细信息。

我尝试按以下方式获取用户个人资料图片:

 FBimage=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[result valueForKeyPath:@"picture.data.url"]]]];

但这需要将近 3 分钟才能获取图片和低于此行的代码,此行也将停止执行。

帮我解决这个问题

谢谢

【问题讨论】:

标签: ios iphone xcode facebook facebook-graph-api


【解决方案1】:

您可以设置AsyncImageView 而不是UIImageview,这样图片就会异步加载

【讨论】:

    【解决方案2】:

    我也有这种图像问题。

    使用https://github.com/rs/SDWebImage

    [imgViewContactImage sd_setImageWithURL:[NSURL URLWithString:@"imagename"]  placeholderImage:[UIImage imageNamed:@"Default"] completed:nil];
    

    先导入“UIImageView+WebCache.h”

    请试试这个。

    分享您的反馈。

    愉快的编码。 :)

    【讨论】:

      【解决方案3】:
          FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
          [login logInWithReadPermissions:@[@"public_profile",@"email",@"picture", @"user_friends"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
              if (error) {
                  // Process error
      
                  NSLog(@"efv");
              } else if (result.isCancelled) {
                  // Handle cancellations
                  NSLog(@"efv");
      
      
      
              } else {
                  // If you ask for multiple permissions at once, you
                  // should check if specific permissions missing
                  if ([result.grantedPermissions containsObject:@"email"]) {
                      // Do work
                      [self fetchUserDetail];
      
      
                  }
              }
      
              [login logOut];
      
          }];
      
      -(void)fetchUserDetail
      {
          if ([FBSDKAccessToken currentAccessToken]) {
              [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id, name,email,gender,picture"}]
               startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
                   if (!error) {
      
      
                       NSLog(@"fetched user:%@", result);
      
      
      
                   }
                   else
                   {
      
                   }
               }];
          }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-06-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-06-24
        • 1970-01-01
        相关资源
        最近更新 更多