open gallery with videos AND photos in iOS

2019-09-01 09:13发布

I was using the UIImagePickerViewController, and i wanted to open the camera roll. But, in my app, i have a button to open my camera roll and another one to open my camera. When i take a picture or record a video, obviously i wanted to see those images in my camera roll. But, in my app, when i start to record a video, he doesn't show up in my camera roll's app.

Here's a little bit of code:

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

[cameraRoll setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];

[cameraRoll setDelegate:self];
[self presentModalViewController:cameraRoll animated:YES];

At this time i can't see my videos in my camera roll's app. Could someone help me?

1条回答
冷血范
2楼-- · 2019-09-01 09:43

You just can do like this:

if([UIImagePickerController isSourceTypeAvailable:
                        UIImagePickerControllerSourceTypePhotoLibrary]) {

     UIImagePickerController *picker= [[UIImagePickerController alloc] init];
     picker.delegate = self;
     picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
     picker.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeMovie, (NSString *)kUTTypeImage, nil];

     [self presentModalViewController:picker animated:YES];
}

Sets the file types you want to get on the property of the PickerViewControllerObject "mediaTypes" and you're ready.

You can found the docs types here.

Regards, Luis

查看更多
登录 后发表回答