我正在一個iOS應用程序,我想有一個垂直桌面與用戶的朋友的大圖片。 (200x200px,100x100pt) 我有它的工作,但它超級慢!我根本無法移動桌面視圖! 我怎樣才能以異樣的方式做到這一點? 這是我當前的代碼: 在viewDidLoad中:iOS中的Facebook SDK個人資料圖片在TableViewCells
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error)
{
self.friends = [result objectForKey:@"data"];
NSLog(@"Found: %u friends", (unsigned)self.friends.count);
[self.leftTableView reloadData];
[self.rightTableView reloadData];
}];
的cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
cell.backgroundColor = [UIColor clearColor];
}
NSDictionary<FBGraphUser> *friend = [self.friends objectAtIndex:indexPath.row];
if (friend)
{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://graph.facebook.com/%@/picture?width=200&height=200", friend.id]];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:data];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(0, 4, 100, 100);
imageView.layer.cornerRadius = 50.0f;
imageView.clipsToBounds = YES;
[cell.contentView addSubview:imageView];
}
return cell;
}
您之前使用過AFNetworking嗎? – sathiamoorthy