我在我的app&获取用户的详细信息。
我尝试按以下方式获取用户个人资料图片:
FBimage=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[result valueForKeyPath:@"picture.data.url"]]]];
但这需要将近3分钟才能获得图片和图片。此行以下的代码也将停止执行。
帮我解决这个问题
感谢
答案 0 :(得分:1)
您可以设置AsyncImageView
而不是UIImageview
,这样Image就会加载Asyncronouslly
答案 1 :(得分:0)
我对图像也有这种问题。
使用https://github.com/rs/SDWebImage
[imgViewContactImage sd_setImageWithURL:[NSURL URLWithString:@"imagename"] placeholderImage:[UIImage imageNamed:@"Default"] completed:nil];
导入" UIImageView + WebCache.h"第一
请试一试。
分享您的反馈意见。
快乐的编码。 :)
答案 2 :(得分:0)
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
{
}
}];
}
}