0
我發現了很多關於使用UIImagePickerController讓用戶從照片應用程序的數據中選擇他們想要的圖像的信息。我想知道如何在3.0上創建相同的效果,因爲它看起來好像很多舊的代碼工作了。另外,我希望用戶能夠從相同的彈出窗口中拍攝新照片。iPhone相機和圖像選擇器
感謝您的幫助!
我發現了很多關於使用UIImagePickerController讓用戶從照片應用程序的數據中選擇他們想要的圖像的信息。我想知道如何在3.0上創建相同的效果,因爲它看起來好像很多舊的代碼工作了。另外,我希望用戶能夠從相同的彈出窗口中拍攝新照片。iPhone相機和圖像選擇器
感謝您的幫助!
工作在3.0,與以前相同;我不相信有任何改變。我剛分配/初始化一個的UIImagePickerController,並將它傳遞給presentModalViewController,像這樣:
- (void) chooseImageFromLibrary {
if(![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) return;
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.allowsImageEditing = YES;
[self presentModalViewController:imagePickerController animated:YES];
}
- (void) chooseImageFromCamera {
if(![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) return;
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.allowsImageEditing = YES;
[self presentModalViewController:imagePickerController animated:YES];
}
實現委託方法,太:
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo {
// Do something with the image here.
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
喜zpasternack:將我的.h文件中是什麼樣的,這些功能......班級必須符合什麼? – PF1 2009-09-13 17:23:03