我是ios开发新手。我正在做一个照片裁剪应用程序。
我想通过单击浏览按钮(我在应用程序中添加)来浏览 iPhone 图片库中的图像,并将其加载到我放置在视图中的 UIImageview。
如何浏览图像?
是否可以浏览完整的手机内存? (就像 asp:FileUpload)。
iPhone 中是否有任何控件可以像 asp:FileUpload 一样使用?
提前致谢。
超级容易做!
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[imagePicker setDelegate:self];
[self presentModalViewController:imagePicker animated:YES];
and
- (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,抱歉。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)