我已经在iPhone应用程序中使用了AVCaptureSession来捕获照片。此外,我还想从PhotosLibrary上拍一张照片。
我已经实现了UIImagePickerController控件和它的所有方法。
我可以打开图书馆,但我不能得到我选择的照片。以及不调用PickerView的方法。这些方法没有响应。
对于图片库,有没有什么不同的方法来用AVCaptureSession实现UIImagePickerController控件?
请告诉我解决方案。
或者建议我替代Overlay的解决方案,因为我既想要动态控件的功能,也想要它们。
提前谢谢。
发布于 2012-12-12 15:19:14
对于打开的图片库,请使用以下内容:
-(IBAction)pickphoto:(id)sender
{
[self startMediaBrowserFromViewController: self usingDelegate: self];
}
- (BOOL) startMediaBrowserFromViewController: (UIViewController*) controller
usingDelegate: (id <UIImagePickerControllerDelegate,
UINavigationControllerDelegate>) delegate{
if (([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum] == NO)
|| (delegate == nil)
|| (controller == nil))
return NO;
UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init];
mediaUI.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
mediaUI.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie,kUTTypeImage, nil];
mediaUI.allowsEditing = YES;
mediaUI.delegate = delegate;
[controller presentModalViewController: mediaUI animated: YES];
return YES;
}
- (void) imagePickerController: (UIImagePickerController *) picker
didFinishPickingMediaWithInfo: (NSDictionary *) info
{
NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
thumbnail = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[self dismissModalViewControllerAnimated:YES];
}要捕获图像,请使用以下命令:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
[self presentViewController:imagePicker animated:YES completion:nil];https://stackoverflow.com/questions/13834610
复制相似问题