[英]How can I browse a picture from iPhone picture library?
我是ios開發的新手。 我正在做一個照片裁剪應用程序。
我想通過單擊瀏覽按鈕(我在我的應用程序中添加)瀏覽iPhone圖片庫中的圖像並將其加載到我放置在視圖中的UIImageview。
我該如何瀏覽圖像?
是否可以瀏覽完整的手機內存? (就像asp:FileUpload)。
iPhone中是否有可用的控件,就像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,抱歉。
如果您運行的是非越獄手機,則無法使用整個文件系統。 也沒有文件系統瀏覽器控件(出於同樣的原因),但是,您可以瀏覽用戶的照片庫,甚至可以使用UIImagePickerController與相機拍照。 文檔: http : //developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.