Camera Preview not filling iPad screen in Landscape - ios

My app is iPad only, and supports only Landscape View.
I have a UIImagePickerController which loads the Camera.
I set it up with the following code:
m_Pickercontroller=[[UIImagePickerController alloc] init ];
m_Pickercontroller.sourceType = UIImagePickerControllerSourceTypeCamera;
m_Pickercontroller.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
m_Pickercontroller.cameraDevice = UIImagePickerControllerCameraDeviceRear;
m_Pickercontroller.showsCameraControls = YES;
m_Pickercontroller.navigationBarHidden = YES;
m_Pickercontroller.toolbarHidden = YES;
m_Pickercontroller.wantsFullScreenLayout = YES;
m_Pickercontroller.allowsEditing=NO;
It is presented with [self presentViewController:m_Pickercontroller animated:YES completion:nil]; I have also tried with a Modal and get the same result.
This occurs on first open of the view only. If you reopen the camera or retake the picture, it goes away.
I have also tried setting the m_Pickercontroller frame size, both before and after it is loaded.
Here is what it looks like, black area is empty, white area is the camera preview. Ignore the white line overlay, that is part of the app.

Ok, so this makes no since whatsoever but what was causing this was the animation:yes
I changed [self presentViewController:m_Pickercontroller animated:YES completion:nil]
to [self presentViewController:m_Pickercontroller animated:NO completion:nil]
and this issue has fixed itself. apparently iOS does not resize the camera preview after animating the view in.

Related

I used a custom view to preview my UIImagePicker preview, how can I extract the same region from the resulting image as was previewed?

In my view I have a UIView that I use to preview the camera. It's a lot smaller than the regular preview view (128x128). I initialise the UIImagePickerController like this:
self.picker = [[UIImagePickerController alloc] init];
self.picker.delegate = self;
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
self.picker.showsCameraControls = NO;
self.picker.view.frame = self.profilePictureView.frame;
I then use [v addSubview:self.picker.view]; to show the camera's preview within my custom UIVIew. So far this works as intended, I see the part of the camera preview that overlaps my custom view in that view (essentially masking the preview with my custom view).
Now I'm trying to get what is displayed in my UIView into a UIImage (resulting in a 128x128 image). I tried using the delegation methods, but I only get the full size image from the camera there. I also tried taking a screenshot from the view but I got lost...
How can I create a UIImage with the exact same content as the view I use to render the camera preview, including size, offset and ratio?

Taking Photos in landscape having issues in my iOS application

I take photos using UIImagePickerController, source type is UIImagePickerControllerSourceTypeCamera.
After i captured, the image editing is changing depending upon the orientation. Herewith i attached my snapshot.
Image 1 : i took this image in portrait mode.
Image 2 : i took this image in landscape mode. here, the top portion is in black color.
My code is :
UIImagePickerController *pickerCamera = [[UIImagePickerController alloc] init];
pickerCamera.delegate = self;
pickerCamera.allowsEditing = YES;
pickerCamera.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:pickerCamera animated:YES completion:NULL];
I want to rotate the image to portrait. Please help me to solve this issue.

Camera photo mode fullscreen on iOS7

Is there a way to set the camera photo mode fullscreen on an iPod 5gen with iOS7.1? When you are going to take a photo, the photo mode is not in fullscreen, only the video mode is in fullscreen, so, is there a way to change it? (I think the same problem must happen on an iPhone 5 and greater).
Here is my code so far, it displays the control but partially, not fullscreen, and the control gets aligned to the top because the camera controls are removed from the view:
self.picker = [[UIImagePickerController alloc] init];
self.picker.delegate = self;
self.picker.allowsEditing = NO;
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.showsCameraControls = NO;
//self.picker.mediaTypes = mediaTypes; //just for the record
self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.picker.modalPresentationStyle = UIModalPresentationFullScreen;
self.picker.cameraOverlayView = [self buildOverlay]; //some custom views
[self presentViewController:self.picker animated:YES completion:NULL];
Thank you very much in advance.
Apply proper CGAffineTransform transformation in order to set camera mode.
Try out the following link this may help you:
here

UINavigation Bar changing tint after using UIImagePickerController

I have a app that can attach a photo to an NSAttributedString in a textView. The UI design has a blue-grey navigation bar with white text.
However, after I use the UIImagePicker, the tint of the NavigationController changes to black text.
- (void)showImagePickerForSourceType:(UIImagePickerControllerSourceType)sourceType
{
_imagePickerController = [[UIImagePickerController alloc] init];
_imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
_imagePickerController.sourceType = sourceType;
_imagePickerController.delegate = self;
if (sourceType == UIImagePickerControllerSourceTypeCamera)
{
_imagePickerController.showsCameraControls = YES;
}
[self presentViewController:_imagePickerController animated:YES completion:nil];
}
I'd post an image of the view before launching the UIImagePicker but I don't have enough reputation points (and I don't really know how to get them either).
And I'd post the image after launching the image picker and picking one and returning from the UIImagePicker, but again, not enough reputation points.
Anyone have any ideas if this is 'normal' or a bug ion iOS? Any suggestions on a workaround?
P.S. If you want to see the images, I can email them to you. Any advice is appreciated.
This indeed seems to be a bug, and has been present since iOS 7 beta 6 (or earlier).
There is another SO post about this with some solutions: UIImagePickerController breaks status bar appearance
This problem can be avoided by changing picker's modal presentation class to be different than full screen (e.g. UIModalPresentationPageSheet)
Code:
imagePickerController.modalPresentationStyle = UIModalPresentationPageSheet;

How to set width and positon ModalDialog in the center before it loads?

I created a modal dialog in my viewController.
dialogViewController *dialog = [[dialogViewController alloc] init];
dialog.modalPresentationStyle = UIModalPresentationFormSheet;
dialog.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
dialog.indexPath = indexPath;
dialog.campaignArray = self.campaignArray;
dialog.view.superview.frame = CGRectMake(dialog.view.superview.frame.origin.x+250, dialog.view.superview.frame.origin.y, dialog.view.superview.frame.size.width-250, dialog.view.superview.frame.size.height);
[self presentViewController:dialog animated:YES completion:nil];
The above changes the width but not the x position of the modal dialog. It works in the modalDialog but then user can see it being resized.
If you want to use
UIModalPresentationFormSheet
the controller will be centred. There is very specific formatting included in this. If you want anything different, you will have to build your own.
The width and height of the presented view are smaller than those of the screen and the view is centered onscreen. If the device is in a landscape orientation and the keyboard is visible, the position of the view is adjusted upward so the view remains visible. All uncovered areas are dimmed to prevent the user from interacting with them.
Try this:
dialogViewController *dialog = [[dialogViewController alloc] init];
dialog.modalPresentationStyle = UIModalPresentationFormSheet;
dialog.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
dialog.indexPath = indexPath;
dialog.campaignArray = self.campaignArray;
[self presentViewController:dialog animated:YES completion:nil];
CGRect dlgFrame = dialog.view.superview.frame;
dlgFrame.size.width -= 250.0;
dialog.view.superview.frame = dlgFrame;

Resources