如何从iPhone图片库浏览图片? [英] How can I browse a picture from iPhone picture library?

查看:112
本文介绍了如何从iPhone图片库浏览图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是ios开发的新手。我正在做一个照片裁剪应用程序。

I am new in ios development. I am doing a photo cropper app.

我想通过点击浏览按钮(我在我的应用程序中添加)浏览iPhone图片库中的图像,并将其加载到我放置在视图中的UIImageview。

I want to browse an image from the iPhone picture library by clicking browse button (that I added in my app) and load it to UIImageview that I placed in a view.

如何浏览图像?。

是否可以浏览完整的手机内存? (就像asp:FileUpload)。

Is it possible to browse the complete phone memory ? (Just like asp:FileUpload).

iPhone中是否有可用的控件,如asp:FileUpload?

Is there any control available in iPhone to use just like asp:FileUpload ?

提前致谢。

推荐答案

超级简单易行!

UIImagePickerController *imagePicker = [[UIImagePickerController     alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

[imagePicker setDelegate:self];
[self presentModalViewController:imagePicker animated:YES];

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{
    [picker dismissModalViewControllerAnimated:YES];
    [picker release];

    // Edited image works great (if you allowed editing)
    //myUIImageView.image = [info objectForKey:UIImagePickerControllerEditedImage];
    // AND the original image works great
    //myUIImageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];
    // AND do whatever you want with it, (NSDictionary *)info is fine now
    //UIImage *myImage = [info objectForKey:UIImagePickerControllerEditedImage];

    UIImage *image =  [info objectForKey:UIImagePickerControllerOriginalImage];

    [customImageView setImage:image]; 

    customImageView.contentMode = UIViewContentModeScaleAspectFill;
}

从stackoverflow获取此代码,没有保存URL,抱歉。

got this code from stackoverflow, didn't save the URL, sorry.

这篇关于如何从iPhone图片库浏览图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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