質問

I have used AVCaptureSession for capture photo in iPhone application. As well as I want to take an image from PhotosLibrary too.

I've implemented UIImagePickerController control and its all methods.

I can open library, But I can't get photo which I've selected. As well as not calling PickerView's methods. No response from those methods.

Is there any different way to implement UIImagePickerController control with AVCaptureSession for photos library?

Please tell me solution.

Or suggest me alternative solution instead of Overlay as I want both functionality with dynamic controls.

Thanks in advance.

役に立ちましたか?

解決

For open photo library use this:

-(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];
}

And for capture a Image use this:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

imagePicker.delegate = self;

[self presentViewController:imagePicker animated:YES completion:nil];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top