我正在使用下面的一段代码从网上下载图像并将其添加到数组中。无法从网页动态设置图像到图像视图
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
UIImage* myImage = [UIImage imageWithData:
[NSData dataWithContentsOfURL:
[NSURL URLWithString: @"http://tcpm.mrlazyinc.com/files/users/themafia/te/beauty/02.jpg"]]];
recipePhotos = [[NSMutableArray alloc] initWithObjects:myImage, @"2.png", @"3.png", @"4.png", @"5.png", @"6.png", @"6.png", @"8.png", @"9.png", @"10.png", nil];
});
我设置到UI使用下面的代码的图像,
UIImageView *recipeImageView = (UIImageView *)[cell viewWithTag:100];
recipeImageView.image = [UIImage imageNamed:[recipePhotos objectAtIndex:indexPath.row]];
在运行时,图像从网页不会显示下载。有什么我失踪的?
仅对第一图像其余ü需要与imageNamed加载:因为他们是其中U UR此项目文件存取权限的图像。 – Shravan