【发布时间】:2013-08-20 05:02:44
【问题描述】:
我是 iPhone 应用开发的新手。在我的代码中,我可以从库中选择多个图像并仅获取 1 个图像的路径。然后我在名为“images”的文件夹中的 Documents 目录中创建该图像的副本并尝试对其进行压缩。现在我想获取所有选择的多个图像的路径,将它们复制到同一文件夹“images”中的文档目录中,然后我想压缩它们。 请告诉我如何在我的代码中完成上述任务。 这是我的代码现在的样子:
- (void) imagePickerController:(QBImagePickerController *)imagePickerController didFinishPickingMediaWithInfo:(NSDictionary *)info
{
if (imagePickerController.allowsMultipleSelection) {
NSArray *mediaInfoArray = (NSArray *)info;
NSLog(@"Selected %d photos", mediaInfoArray.count);
NSData *webData = UIImagePNGRepresentation([[mediaInfoArray objectAtIndex:0] objectForKey:@"UIImagePickerControllerOriginalImage"]);
NSLog(@"web data length is: %u",[webData length]);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *localFilePath = [documentsDirectory stringByAppendingString:@"/images.png"];
[webData writeToFile:localFilePath atomically:YES];
NSLog(@"localFilePath.%@",localFilePath);
}
【问题讨论】:
-
这会对您有所帮助。 stackoverflow.com/questions/8376511/…
-
我投反对票,因为你没有接受答案。
标签: iphone ios cocoa-touch ios6