IOS – 从Parse.com后端下载图片

或者我有一个应用程序,一直从parsing后端下载大图像。 在android中,您可以使用它们的URI将图像下载为stream,并将特定的尺寸大小设置为我要下载的位图。 通常这是通过使用BitmapFactory库来完成的,并允许我下载一个缩小尺寸的位图,从而节省我的应用程序的时间。 在IOS平台上有这个方法吗? 这是我目前正在做的,但是当我下载15全尺寸的图像,我得到了大量的加载时间:

//where photoQuery is a Parse.com database query that returns the photo as the first object PFObject *photoObject = [photoQuery getFirstObject]; PFFile *photoFile = (PFFile *)[photoObject objectForKey:@"fullSizedImage"]; UIImage *fullImage = [UIImage imageWithData:photoFile.getData]; 

IOS是否支持类似于BitmapFactory或这个常见的Androiddevise模式?

PFFile有一个名为– getDataInBackgroundWithBlock:的方法。 可以这样使用:

 [photoFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) { if(!error) { [imageView setImage:[UIImage imageWithData:data]; } } 

或者你可以使用另一个叫做- getDataStreamInBackgroundWithBlock:方法。 它与上面的类似。 区别在于块的第一个参数是NSInputStream

PFImageView应该帮助你同步加载这些图像。 您可以尝试使用云代码缩略图。