open gallery with videos AND photos in iOS

冷暖自知 提交于 2019-12-11 18:19:08

问题


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:


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



来源:https://stackoverflow.com/questions/12165761/open-gallery-with-videos-and-photos-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!