앱의 콘텐츠 로딩에 문제가 있습니다. 앱에서 데이터를 가져 오지만 이미지를로드하는 데 많은 시간이 걸리는 것으로 나타났습니다.로드 할 가능성이 있습니다. afterword 이미지. 코드는 다음과 같습니다 : 당신이 세부 사항을 더 원하는 경우앱이 이미지로드 문제로 인해 속도가 느려짐
NSDictionary *dict=[discussionArray objectAtIndex:indexPath.row];
UIImageView *avatarimage = (UIImageView *)[cell viewWithTag:4];
NSString *photoStrn=[dict objectForKey:@"photo"];
dispatch_async(dispatch_get_global_queue(0,0), ^{
NSString *u=[NSString stringWithFormat:@"http://%@",photoStrn];
NSURL *imageURL=[NSURL URLWithString:u];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
dispatch_sync(dispatch_get_main_queue(), ^{
UIImage *dpImage = [UIImage imageWithData:imageData];
if (dpImage==nil)
{
dpImage = [UIImage imageNamed:@"profileImage.png"];
}
avatarimage.image = dpImage;
});
나는 :) 제공
이 하나 http://stackoverflow.com/questions/9786018/loading-an-image-into-uiimage-asynchronously – Balu
이가이 모양 가지고 참조 답변 : http://stackoverflow.com/a/15270523/2106940 – Jeremy