大佬教程收集整理的这篇文章主要介绍了iphone – 从照片库中选择多个图像,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在制作iPad的应用程序,并希望让用户能够从其照片库中多次选择图像。我已经有一个工作代码供用户一次选择一个图像。 (不是我需要的)
我已经下载并查看了ELC图像采集器示例代码,但该代码与iOS 5或Xcode 4不兼容。即,它具有ARC和左右编译问题,其使用版本和dealloc遍及全部。
我很沮丧,苹果还没有为我们的开发人员在大多数iPhone / ipad应用程序中为这个最常请求的功能创建内置API。 (不是一个,但多选图)
我正在做的是让用户继续选择他们想要的照片,将这些文件保存在应用程序文档目录中,直到他们点击完成按钮。看到这里我的示例代码,希望它会为您节省经历资产库的痛苦
-(IBACtion)SELEctExiTingPicture { //Specially for fing iPAD UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; imagePicker.sourCEType = UIImagePickerControllersourceTypePhotoLibrary; imagePicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage]; popoverController = [[UIPopoverController alloc] initWithContentViewController:imagePicker]; [popoverController presentPopoverFromRect:CGRectMake(0.0,0.0,400.0,300.0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } //Done button on top - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { //NSLog(@"Inside navigationController ..."); if (!doneButton) { doneButton = [[UIBarButtonItem alloc] initWithtitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@SELEctor(saveImagesDone:)]; } viewController.navigationItem.rightBarButtonItem = doneButton; } - (IBACtion)saveImagesDone:(id)sender { //NSLog(@"saveImagesDone ..."); [popoverController dismissPopoverAnimated:YES]; } -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage : (UIImage *)image ediTingInfo:(NSDictionary *)ediTingInfo { //DONT DISMISS //[picker dismissModalViewControllerAnimated:YES]; //[popoverController dismissPopoverAnimated:YES]; IMAGE_COUNTER = IMAGE_COUNTER + 1; imageView.image = image; // Get the data for the image NSData* imageData = UIImageJPEGRepresentation(image,1.0); // Give a name to the file NSString* incrementedImgStr = [NSString StringWithFormat: @"UserCustomPoTraitPic%d.jpg",IMAGE_COUNTER]; NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString* documentsDirectory = [paths objectATindex:0]; // Now we get the full path to the file NSString* fullPathToFile2 = [documentsDirectory StringByAppendingPathComponent:incrementedImgStr]; // and then we write it out [imageData writeToFile:fullPathToFile2 atomically:NO]; }
//现在使用此代码获取用户选择的图片。在你的代码中从任何你想要的地方调用它
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,YES); NSString* documentsPath = [paths objectATindex:0]; NSString* DATAFILE = [documentsPath StringByAppendingPathComponent:@"UserCustomPoTraitPic1.jpg"]; NSData *poTraitImgData = [NSData dataWithContentsOfFile:DATAFILE]; BACkgroundImagePoTrait = [UIImage imageWithData:poTraitImgData];
以上是大佬教程为你收集整理的iphone – 从照片库中选择多个图像全部内容,希望文章能够帮你解决iphone – 从照片库中选择多个图像所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。