我工作的项目之一,我必须在iPhone设备照片库中保存捕获的图像。如何从iPhone设备照片库中的相机中保存拍摄图像?
我想问问如何通过code.Here实现这个下面我为我贴的代码是什么: -
- (空)imagePickerController:(*的UIImagePickerController)选择器didFinishPickingMediaWithInfo:(NSDictionary的*)信息{
[picker dismissModalViewControllerAnimated:YES];
imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
imgglobal =imageView.image;
NSString *newFilePath = [NSHomeDirectory() stringByAppendingPathComponent: @"~/Users/abc/Library/Application Support/iPhone Simulator/User/Applications/SAVE_IMAGE_TEST1.JPG"];
NSData *imageData = UIImageJPEGRepresentation(imageView.image, 1.0);
NSData *data = imageData;
if (imageData != nil) {
[imageData writeToFile:newFilePath atomically:YES];
}
if ([[NSFileManager defaultManager] createFileAtPath:@"~/Users/abc/Library/Application Support/iPhone Simulator/User/Applications/SAVE_IMAGE_TEST1.JPG" contents:data attributes:nil])
{
UIAlertView *successAlert = [[UIAlertView alloc] initWithTitle:@"Success" message:@"Image was successfully saved to the Photo Library." delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil];
[successAlert show];
[successAlert release];
} else {
UIAlertView *failureAlert = [[UIAlertView alloc] initWithTitle:@"Failure" message:@"Failed to save image to the Photo Library." delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil];
[failureAlert show];
[failureAlert release];
}
}
但我的应用程序显示故障发生警报,请给我正确的代码将捕获的图像保存到iPhone设备照片库。
在此先感谢其非常紧迫
@AmanGupta007我面临同样的问题,请给我一些建议如何可能? – 2014-03-26 10:32:58