0
我将照片相册中的图像作为NSData存储在我的应用程序文档目录中,并将它们显示在UITableView中。我的表现有问题。将图像保存到应用程序目录需要很长的时间,并且在将它们加载到TableView时遇到同样的问题。这是我的代码来存储图片:UITableView中的NSData的UIImage - 性能问题
//Convert UIImage to NSData
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)];
//Save image to app documents directory
NSError *error;
[imageData writeToFile:fullImagePath options:NSDataWritingAtomic error:&error];
这就是我将它们加载到的UITableView:
NSData *imageData = [NSData dataWithContentsOfFile:path];
UIImage *myImage = [UIImage imageWithData:imageData];
cell.imageView.image = myImage;
什么会引起这些性能问题?是否有任何其他方式来存储和检索应用程序文档目录中的图像?
谢谢,我会尝试缩放和异步加载。 – Guferos 2013-03-01 12:19:36