这是我的代码:
- (voID)imagePickerController:(UIImagePickerController *)picker dIDFinishPickingMediawithInfo:(NSDictionary *)info { Nsstring *mediaType = [info valueForKey:UIImagePickerControllerMediaType]; if([mediaType isEqualToString:(Nsstring*)kUTTypeImage]) { UIImage *photoTaken = [info objectForKey:@"UIImagePickerControllerOriginalimage"]; self.imageVIEw.image = photoTaken; //Save Photo to library only if it wasnt already saved i.e. its just been taken if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) { UIImageWritetoSavedPhotosAlbum(photoTaken,self,@selector(image:dIDFinishSavingWithError:contextInfo:),nil); } } [picker dismissVIEwControllerAnimated:YES completion:NulL];}- (voID)image:(UIImage *)image dIDFinishSavingWithError:(NSError *)error contextInfo:(voID *)contextInfo { UIAlertVIEw *alert; if (error) { alert = [[UIAlertVIEw alloc] initWithTitle:@"Error!" message:[error localizedDescription] delegate:nil cancelbuttonTitle:@"OK" otherbuttonTitles:nil]; [alert show]; }}
我试过这样做下面的代码,但我不知道它在哪里将图像保存到我的iPhone设备中的App资源:
Nsstring *documentsDirectory = [NSSearchPathForDirectorIEsInDomains(NSdocumentDirectory,NSUserDomainMask,YES) objectAtIndex:0]; Nsstring *sourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"EMS_FolDER"]; Nsstring *folderPath = [documentsDirectory stringByAppendingPathComponent:@"files"];
任何来源或链接供参考,表示赞赏.
谢谢您的帮助!
- (IBAction)takePhoto{ UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init]; imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; imagePickerController.editing = YES; imagePickerController.delegate = (ID)self; [self presentModalVIEwController:imagePickerController animated:YES];}- (voID)imagePickerController:(UIImagePickerController *)picker dIDFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo{ [self.library saveImage:image toAlbum:@"touch Code Magazine" withCompletionBlock:^(NSError *error) { if (error!=nil) { NSLog(@"Big error: %@",[error description]); } }]; [picker dismissModalVIEwControllerAnimated:NO];}
这已在这里解释,一个很好的教程..
http://www.touch-code-magazine.com/ios5-saving-photos-in-custom-photo-album-category-for-download/
总结以上是内存溢出为你收集整理的ios – 如何将图像从相机保存到iPhone库中的特定文件夹?全部内容,希望文章能够帮你解决ios – 如何将图像从相机保存到iPhone库中的特定文件夹?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)