open gallery with videos AND photos in iOS - ios

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?

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

Related

How to customize Picking video style in objective c?

I am working with video marge app. When i pick video from library using UIImagePicker, it is a default style like this photo.
But I want like this.
If i use ELCImagePicker i can pick video. but when i try to set the video in a video player it show null video url. Please help.
You can use mediative property of UIImagePickerController for selecting media of type video. here is sample code .
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];
[self presentModalViewController:imagePicker animated:YES];

How do I solve gallery scroll stuttering in a landscape-oriented UIImagePickerController?

I have tried a couple of different methods for presenting a landscape-oriented UIImagePickerController in a landscape-only app (not by my choice) I'm working on.
When I (successfully) present the gallery in landscape format and scroll through the images, there is a truly horrible stutter!
The current technique I am using is this:
- (void)presentImagePickerController:(UIImagePickerControllerSourceType)sourceType {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
if (isDeviceIPad) {
picker.modalPresentationStyle = UIModalPresentationFormSheet;
picker.preferredContentSize = [UIScreen mainScreen].bounds.size;
}
picker.sourceType = sourceType;
picker.delegate = self;
picker.allowsEditing = YES;
[self presentViewController:picker
animated:YES
completion:nil];
}
I cannot go with a solution which uses private interfaces, since the app has to pass App Store review. I'd prefer not to use a third-party library, since my boss is against that idea.
My iPad is a 3rd generation, model MD334LL/A that's running iOS 8.1.
From the UIImagePickerController class reference found here: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImagePickerController_Class/index.html
On iPad, the correct way to present an image picker depends on its source type, as summarized in this table:
Camera: Use full screen
Photo Library: Must use a popover
Saved Photos Album: Must use a popover
Answer: Since I want to present the Saved Photos Album, I need to present the picker by using a popover.
- (void)presentImagePickerController:(UIImagePickerControllerSourceType)sourceType {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = sourceType;
picker.delegate = self;
picker.allowsEditing = YES;
if (isDeviceIPad() && sourceType == UIImagePickerControllerSourceTypeSavedPhotosAlbum) {
picker.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *presentationController = picker.popoverPresentationController;
presentationController.permittedArrowDirections = UIPopoverArrowDirectionAny;
presentationController.sourceView = self.presentPickerButton;
presentationController.sourceRect = self.presentPickerButton.bounds;
}
[self presentViewController:picker
animated:YES
completion:nil];
}

iOS 8 UIImagePickerController to take photos only photos

I am using an UIImagePickerController with sourceType = UIImagePickerControllerSourceTypeCamera;
However I want to specify that I want to take only photos, not videos , (in a native camera user can switch to video) is there a way to do so ?
Here is the code I am using :
if (([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera] == NO))
return ;
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
// Displays a control that allows the user to choose picture or
// movie capture, if both are available:
cameraUI.mediaTypes =
[UIImagePickerController availableMediaTypesForSourceType:
UIImagePickerControllerSourceTypeCamera];
// Hides the controls for moving & scaling pictures, or for
// trimming movies. To instead show the controls, use YES.
cameraUI.allowsEditing = NO;
cameraUI.delegate = self;
[self presentViewController:cameraUI animated:YES completion:nil];
My 1st guess was is to change the sourceType = UIImagePickerControllerSourceTypeCamera; but the other options are galleries options.
My 2nd guess is: to change the array of mediaTypes but I don't know to which 1
https://developer.apple.com/library/ios/documentation/uikit/reference/uiimagepickercontroller_class/index.html#//apple_ref/c/tdef/UIImagePickerControllerCameraCaptureMode
cameraUI.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;

Get all GIF images saved on iPhone/iPad camera roll

As far as I know, it is very easy to get all the videos from the Camera Roll, just by doing something like this:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];
[self presentViewController:imagePicker animated:YES completion:nil];
My question is, how is it possible to get all the GIF saved on the camera roll?
I have downloaded the app 'GifBoom Pro' and it does it.
Thank you very much.
I know this is an old question. But for anyone else to come, you'll need to use the Photos framework and use requestImageDataForAsset:imageData:imageUTI,Orientation,Info and compare the image UTI against the string of com.compuserve.gif. ALAssetsLibrary will become deprecated by iOS 9.0

Open camera roll on the latest photo

I know already how to open the camera roll:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
[picker setDelegate:self];
[picker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[picker setAllowsEditing:YES];
[self presentModalViewController:picker animated:YES];
But I want it to go directly to the latest picture. It does it when you use the iPhone original camera. When you click on the thumbnail of the taken photo, the camera roll open and display it directly.
Is it possible to do this way?

Resources