When I open the UIImagePickerControllerSourceTypePhotoLibrary, the frame of the editing view is not in alignment with the picture. Here is my code:
UIImagePickerController * picker = [[UIImagePickerController alloc] init] ;
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.allowsEditing=YES;
[self presentViewController:picker animated:YES completion:^{}];
Here is a screenshot showing the problem:
As you can see, the top part of the editing view frame is above the actual image. Any help is appreciated.
EDIT: This issue only occurs with the iPhone 6 and 6+. Works fine with iPhone 5s.
Related
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.
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...
I was working on creating a custom Camera Overlay and setting it to UIImagePickerController's CameraOverlayView property.
However since I am not enrolled in to Apple's developer program I can not really deploy and test the application package on actual device.
I also debugged my code and it appears that on Simulator you can not really choose and set imagePicker.sourceType property to the UIImagePickerControllerSourceTypeCamera. Because camera functionality is not available on simulator.
Am I right in my thinking ?
Or am I missing something and there is a way to set the CameraOverlayView property and test it on simulator ?
Here is the example of my code:
- (IBAction)takePicture:(id)sender
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc]init];
// Check what is possible or supported on simulator, otherwise,
//just pick from Photo library
if ( [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
if ( [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) {
imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
} else {
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
// Allow edit
[imagePicker setEditing:YES animated:YES ];
[imagePicker setAllowsEditing:YES];
imagePicker.delegate = self;
// set custom Overlay
//imagePicker.cameraOverlayView = ( not working in simulator )
//Display the imagePicker on the screen
[self presentViewController:imagePicker animated:YES completion:NULL];
}
You are correct, the camera does not work in the iOS simulator.
I have an iPhone-only app. It allows users to capture videos using the default UIImagePickerController.
When you run the app on an iPad 2 running iOS 7, the UIImagePickerController does not show the "swap camera" button in the upper right-hand corner. This is the button that allows the user to switch between the front-facing and rear-facing cameras. I have no idea why the button is not there. The button is there on iPhone and on iPad 3. The problem only happens on iPad 2. See attached screenshot.
Weird behavior - if you rotate the iPad to landscape mode, and tap where the button is supposed to be, it actually switches to the front facing camera. So the functionality is there, but for some reason the button is not visible.
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
picker.allowsEditing = YES;
picker.videoMaximumDuration = 1800;
picker.videoQuality = UIImagePickerControllerQualityTypeMedium;
[self.navigationController presentViewController:picker animated:YES completion:nil];
[picker release];
Image here:
http://i.imgur.com/1IAeMU0.png
The UIImagePickerController only works on portrait, so you have to make a workaround to handle the orientation switch, like subclassing the UIImagePickerController, and changing the view when the orientation changes.
Credits: https://stackoverflow.com/a/21484101/736384
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.