现在我加载图片查看文件的URL和它花了很长时间。我甚至把它作为高优先级放在主线上,但它仍然很慢。这实际上是在6个图像的循环中。我的问题是:快速的方式来加载图像
有没有加载图像比这个观点更快的方法?像文件url的替代方案?
//check the filetype
if ([fileType isEqual: @"image"])
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
//get image
NSURL *imageFileUrl = [[NSURL alloc] initWithString:file.url];
NSData *imageData = [NSData dataWithContentsOfURL:imageFileUrl];
dispatch_async(dispatch_get_main_queue(), ^{
imageView.image = [UIImage imageWithData:imageData];
});
});
}
我的图片在该预设的质量和大小是iphone屏幕的大小不管是一个5,6或6加
self.camera = [[LLSimpleCamera alloc] initWithQuality:AVCaptureSessionPreset1280x720
position:CameraPositionBack
videoEnabled:YES];
感谢,
仅供参考 - 如果'file.url'实际上是将一个文件路径作为一个字符串返回,那么您不能使用'initWithString'创建'NSURL'。你需要使用'initFileURLWithPath:'。但是,如果'file.url'返回类似'file:// somepath/to/file'的东西,那么你所拥有的就很好。 – rmaddy
回答你的问题,不,没有任何加载图像的快捷方式。 – rmaddy
这可能会有所帮助:https://github.com/rs/SDWebImage – kpsharp