我有这个滚动视图,我从 URL 中加载了几张图片。问题是滚动视图在全部加载之前不会显示它们中的任何一个。我想在我完成加载她的那一刻显示每张图片。
我的代码如下所示:
-(void)loadPhotosToLeftscroll{
for (int count = 0 ; count < [leftPhotoArray count]; count++) {
NSLog(@"nextPhotoHight: %f",nextLeftPhotoHight);
NSMutableDictionary *photoDict;
photoDict = [leftPhotoArray objectAtIndex:count];
float photoHight = [[photoDict objectForKey:@"photos_height"]floatValue];
float photoWide= [[photoDict objectForKey:@"photos_width"]floatValue];
NSString *photoPath = [photoDict objectForKey:@"photos_path"];
NSData * imageData = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString:photoPath]];
UIImage *image = [[UIImage alloc] initWithData:imageData];
UIImageView *photoView = [[UIImageView alloc]initWithFrame:CGRectMake(10 , nextLeftPhotoHight, photoWide, photoHight )];
[photoView setImage:image];
[photoView.layer setMasksToBounds:YES];
[photoView.layer setCornerRadius:6];
nextLeftPhotoHight = photoView.frame.size.height + photoView.frame.origin.y + 10;
[leftBlockScroll addSubview:photoView];
}
}