0
我有這個滾動視圖,我加載到他幾個URL的圖像。 問題是,滾動視圖不顯示任何直到所有加載。 我想在我完成加載她的時刻顯示每個圖像。如何從URL單獨加載少量圖像以滾動視圖? objective-c
我的代碼看起來是這樣的:
-(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];
}
}
具體的東西[像這樣](http://www.alterplay.com/ios-dev -tips/2009/10/asynchronous-uiimage-from-web.html)可以正常工作 – Dima