如何在模仿iPhone默认图库的应用程序中实现图库? [英] How to implement an image gallery inside an application mimicking the iPhone's default gallery?

查看:125
本文介绍了如何在模仿iPhone默认图库的应用程序中实现图库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的iPhone应用程序中实现一个图像库,它只能从设备库中选择那些从应用程序内部选择的图像或从应用程序内部拍摄的图片。请提供任何简单方法的建议。

I want to implement an image gallery inside my iPhone app which will only have those images from device gallery that have been either selected from inside the app or pictures taken from inside the app. Please advice on any simple methods to do so.

推荐答案

您可以尝试 Three20 ,这是一个非常好的框架来完成这样的任务。

You can try Three20, it's a very nice framework for doing such a task.

这是你可以使用的一些示例代码。

Here is some piece of sample code you can use.

在界面中:

//IBOutlet UIImageView *image;
UIImagePickerController *imgPicker;
IBOutlet UIImageView *imageview;

然后在viewDidLoad中:

Then in viewDidLoad :

self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.allowsImageEditing = YES;
//self.imgPicker.delegate = self;
self.imgPicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
//imgarry = [[NSArray alloc]initWithObjects:@"terms.png",@"change-profile.png",nil];
UIImage* img = [UIImage imageNamed:@""];
UIImageWriteToSavedPhotosAlbum(img,nil,nil,nil);

然后在按钮点击:

UIImagePickerController *picker = [[UIImagePickerController alloc]init];
imgPicker.delegate = self;
imgPicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentModalViewController:imgPicker animated:YES];
[imgPicker release];

这就是我实现这一点的方法,不要忘记为图像设置@property和@synthesis-查看和UIImagePicker。

This is how i achieve this, don't forget to set @property and @synthesis for image-view and UIImagePicker.

这篇关于如何在模仿iPhone默认图库的应用程序中实现图库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆