UIImagePicker Popup in Portrait mode only In iPhone? - ios

UIImagePicker opening in Portraite mode while my app is in ladscape mode.
code for UIimage picker is
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:nil];

The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified, with one exception. You can assign a custom view to the cameraOverlayView property and use that view to present additional information or manage the interactions between the camera interface and your code.
Reference from Apple docs

Related

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

Default flash controls of camera app appears truncated

We are developing and iOS application and in one of the View Controllers UIImagePickerController is used to present the camera to the user. In the view controller there is a UIButton and in the event listener method we have the following code.
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
[self presentViewController:imagePicker animated:YES completion:NULL];
Camera app is presented properly, but the flash control titles are appearing truncated (Auto is appearing as Au..., Off is appearing as ...) as shown in the screen shots. It would be great if someone can help out. I'm guessing it's some app configuration issue, as the same code works in a different project.
Thanks in advance.

Landscape only iPad app displays UIImagePicker in portrait orientation

I have an iPad app that only supports landscape orientations, however when I try to display a UIImagePickerController inside a UIPopoverController it always appears in portrait mode. i.e. rotated 90 degrees from the rest of the UI. Does anyone know how I can make this appear in the same orientation as the ViewController I'm presenting it in?
I'm displaying the imagePicker like this:
self.picker = [[FFSImagePicker alloc] init];
picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
picker.delegate = self;
picker.toolbarHidden = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.allowsEditing = NO;
picker.showsCameraControls = YES;
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
self.photoPickerPopover = popover;
[self.photoPickerPopover presentPopoverFromRect:photoButton.bounds inView:photoButton permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
FFSImagePicker is just a subclass of UIImagePickerController where I tried to make sure the supported orientations were only landscape, but that had no effect.
Thanks for any help...
OK, I solved this, the issue was that I was presenting the UIImagePickerController in a UIPopover which Apple says not to do when the source type is the camera, instead present it full screen just like you would any other view controller.
Hope this helps someone else too...

Camera controls not visible on iOS 7

I have used Image Picker Controller to call device camera. The code listed below works fine below iOS 7. But when I use the Same code on iOS 7 to launch camera I am unable see "Use" and "Cancel" buttons.
- (void)getCameraPicture {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = NO;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
[self presentViewController:picker animated:YES completion:NULL];
}
Any help is appreciated.
Update:
When I try to run this code in a sample app then it works fine.(sample app contains single view). But when I put it inside my project the buttons doesn't show.
in the code should be there:
...
picker.showsCameraControls = YES;
have you checked this #property (nonatomic) BOOL showsCameraControls in UIImagePickerController.

App freezes on camera shutter

I am working on an app using iOS 7. Sometimes I face a problem in iOS 6 device when i open the camera. It freezes on camera shutter. Although I set ARC to YES. I couldn't understand where is the problem?
I used the code for this
self.cameraUI = [[UIImagePickerController alloc] init];
self.cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
self.cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
self.cameraUI.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.cameraUI.navigationBarHidden = YES;
self.cameraUI.showsCameraControls = NO;
self.cameraUI.wantsFullScreenLayout = YES;
self.cameraUI.delegate = self;
[self.cameraView addSubview:self.cameraUI.view];
You shouldn't be doing addSubview: to a UIImagePickerController's view. Instead it is recommended to present the UIImagePickerController and implement its delegates to get the selected image.
From Apple docs for How to use UIImagePickerController?,
Present the user interface. On iPhone or iPod touch, do this modally (full-screen) by calling the presentViewController:animated:completion: method of the currently active view controller, passing your configured image picker controller as the new view controller.
This is how you can present it from your controller,
[viewcontrollerObj presentViewController:self.cameraUI animated:YES completion:nil];
Hope that helps!

Resources