如何从iPhone图片库浏览图片?

Aru*_*run 7 iphone xcode image ios

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

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

我该如何浏览图像?

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

iPhone中是否有可用的控件,就像asp:FileUpload一样?

提前致谢.

Pau*_*nne 9

超级容易!

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

[imagePicker setDelegate:self];
[self presentModalViewController:imagePicker animated:YES];
Run Code Online (Sandbox Code Playgroud)

- (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;
}
Run Code Online (Sandbox Code Playgroud)

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