unable to resize UIImagePickerController more than a certain height - ios

I am trying to incorporate UIImagePickerController into my app by adding it through subview. But somehow I am unable to increase its height beyond a certain fixed size(the size in default camera app). Is there a way to increase the height? Like the "Fast camera" app does it.
Here is my code:
self.picker = [[UIImagePickerController alloc] init];
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
self.picker.showsCameraControls = NO;
self.picker.navigationBarHidden = YES;
self.picker.toolbarHidden = YES;
self.picker.delegate = self;
[self.picker.view setFrame:CGRectMake(0, 65, 320, 444)];
[self.view addSubview:self.picker.view];

use cameraOverlayView property UIImagePickerController class for custom view

i don't know it exactly you want like.
try this one:
self.picker = [[UIImagePickerController alloc] init];
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.picker.showsCameraControls = YES;
self.picker.delegate = self;
[self.picker.view setFrame:CGRectMake(0,0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
[self.navigationController.view addSubview:self.picker.view];
i checked it working good in my app.
Happy Coding...

Related

How to open camera with frame in iOS

How to bound iPhone camera inside a frame like below image.
Let the camera opens on full screen but the reading area will be only non blurred background in short i want to develop a screen shown in image.
I have tried this code but it is not working...
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
picker.showsCameraControls = YES;
picker.navigationBarHidden = YES;
picker.view.frame = CGRectMake(0, 10, 200, 20); // NOT WORKING !!!
picker.toolbarHidden = YES;
picker.wantsFullScreenLayout = NO;
// picker.delegate = delegate;
CGAffineTransform transform = CGAffineTransformMakeTranslation(0.0f, 50.0f);
transform = CGAffineTransformScale(transform, 1.2f, 1.2f);
picker.cameraViewTransform = transform;
[self presentViewController:picker animated:YES completion:nil];
how do i do this?
Thanks in advance!
You have to create custom camera for that. As I can see in the image you need to scan barcode. For that you need to use
AVCaptureSession
AVCaptureVideoPreviewLayer

How to set frame in center xcode

Im making iPhone app using frame, my frame is not in center and it repeats. I want to set in center and I hate when my frames repeats multiple times.
Im using following code:
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
// picker.delegate = self;
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
// creating overlayView
UIView* overlayView = [[UIView alloc] initWithFrame:picker.view.frame];
// letting png transparency be
overlayView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"f2.png"]];
[overlayView.layer setOpaque:NO];
overlayView.opaque = NO;
picker.showsCameraControls = NO;
picker.cameraOverlayView = overlayView;
//[self presentModalViewController:picker animated:YES];
[self presentViewController:picker animated:YES completion:nil];
Am I missing something ?
TNX in advance.
I'm not sure, what you are asking, but maybe changing from frame to bounds could solve you problem:
UIView* overlayView = [[UIView alloc] initWithFrame:picker.view.bounds];

Running camera on iPhone (OS 7)

I have code that perfectly works on iPad
self.clockInEmployee = nil;
self.clockInEmployee = [[userInfo userInfo] valueForKey:#"employee"];
self.clockInEmployeeRole = [[userInfo userInfo] valueForKey:#"role"];
CLog (#"PIN %#", self.clockInEmployee.pin);
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = (id)self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = YES;
picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
picker.cameraOverlayView = self.cameraOverlay.view;
if (isPhone())
{
picker.view.frame = CGRectMake(0, 748, 1024, 748);
[mainNavController.view addSubview:picker.view];
[UIView animateWithDuration:0.5 animations:^{
picker.view.frame = CGRectMake(0, 0, 1024, 748);
} completion:^(BOOL finished){
[picker viewDidAppear:YES];
}];
}
modViewController = picker;
but on iPhone when it try to launch camera I only observe black screen.
But if I try to launch it like that:
[appPresentingViewController presentViewController:picker animated:YES completion:nil];
it launches successfully. But in my particular project it causes some UI problems, so it can't be used.
How can I make this
if (isPhone())
{
picker.view.frame = CGRectMake(0, 748, 1024, 748);
[mainNavController.view addSubview:picker.view];
[UIView animateWithDuration:0.5 animations:^{
picker.view.frame = CGRectMake(0, 0, 1024, 748);
} completion:^(BOOL finished){
[picker viewDidAppear:YES];
}];
}
work for both iPad and iPhone ?
Please try this:-
//create an overlay view instance
OverlayView *overlay = [[OverlayView alloc]
initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGTH)];
//create a new image picker instance
UIImagePickerController *picker =
[[UIImagePickerController alloc] init];
//set source to video!
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
//hide all controls
picker.showsCameraControls = NO;
picker.navigationBarHidden = YES;
picker.toolbarHidden = YES;
//make the video preview full size
picker.wantsFullScreenLayout = YES;
picker.cameraViewTransform =
CGAffineTransformScale(picker.cameraViewTransform,
CAMERA_TRANSFORM_X,
CAMERA_TRANSFORM_Y);
//set our custom overlay view
picker.cameraOverlayView = overlay;
//show picker
[self presentModalViewController:picker animated:YES];
for further refrence -here
You may like to go through apples sample project of AVCAM it can be found here
what you need to do is something like this:
AVCaptureSession *avcam = [[AVCaptureSession alloc] init];
AVCaptureVideoPreviewLayer *previewLayer =
[AVCaptureVideoPreviewLayer layerWithSession:avcam];
previewLayer.frame = self.previewView.bounds;
[self.previewView.layer addSublayer:previewLayer];

How to add the UIImagePickerController in the custom view?

How to add the UIImagePickerController in the view ? If I add the image picker to the view, its show on the full screen. I need to show the on the centre of the view, But UIImagePickerController hide the navigation bar.
How add the UIImagePickerController in the view and also show the navigation bar ?
I am using the following code, I got the output like this(screenshot).
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
imagePicker.showsCameraControls = NO;
imagePicker.navigationBarHidden = NO;
imagePicker.toolbarHidden = YES;
imagePicker.wantsFullScreenLayout = NO;
imagePicker.delegate = self;
imagePicker.cameraOverlayView = cameraOverlayView;
[self presentViewController:imagePicker animated:NO completion:nil];
I need some for show the navigation bar while add the UIImagePickerController in the view. Thanks in advance.
If you are develop application for iPad then you can use popoverviewcontroller to show imagepickerviewcontroller with navigation bar
please see thie link :
How to use UIImagePickerController in iPad?
Correct way to customize media capture here using Assets Library.
Simple way (in some cases) is using overlay view with frame size of whole screen and add controls on that view which simulate navigation bar.
if (_pickerOverlay == nil) {
_pickerOverlay = [[UIView alloc] initWithFrame:self.view.bounds];
//red transparent tint for demo
_pickerOverlay.backgroundColor = [UIColor colorWithRed:1.0
green:0.0
blue:0.0 alpha:0.6];
UIButton *btnBack = [UIButton buttonWithType:UIButtonTypeSystem];
btnBack.frame = CGRectMake(20, 20, 250, 40);
[btnBack setTitle:#"Custom buttom" forState:UIControlStateNormal];
btnBack.backgroundColor = [UIColor whiteColor];
[_pickerOverlay addSubview:btnBack];
}
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = NO;
picker.cameraOverlayView = _pickerOverlay;
[self presentViewController:picker animated:YES completion:nil];

how to display cameracview in popOvewView in ipad

Hi for all i am using popoverController displaying for camera view but i am not getting camera view anybody please help me here s my code.
picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls=NO;
picker.delegate = nil;
picker.allowsEditing = NO;
UIViewController *containerController = [[UIViewController alloc] init];
containerController.contentSizeForViewInPopover = CGSizeMake(768, 750);
[containerController.view addSubview:picker.view];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:containerController];
self.popoverController = popover;
popoverController.delegate = self;
[popover release];
CGPoint point = {760,750};
CGSize size = {760,750};
[popoverController presentPopoverFromRect:CGRectMake(point.x, point.y, size.width, size.height)
inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
here i am getting empty popoverView? video is not displayed.
I couldn't find the issue. Please check with this code:
picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls=NO;
picker.delegate = nil;
picker.allowsEditing = NO;
picker.contentSizeForViewInPopover = CGSizeMake(768, 750);
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
self.popoverController = popover;
popoverController.delegate = self;
[popover release];
CGPoint point = {760,750};
CGSize size = {760,750};
[self.popoverController presentPopoverFromRect:CGRectMake(point.x, point.y, size.width, size.height) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

Resources