Display full camera in iPad - objective-c

I am try to display full camera in iPad. but it displays very small camera. I am using below this code.
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate=self;
imagePicker.cameraOverlayView.frame = CGRectMake(0, 0, 1000, 700);
[imagePicker.cameraOverlayView sizeToFit];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
imagePicker.wantsFullScreenLayout = YES;
[imagePicker release];
[popover presentPopoverFromRect:CGRectMake(0,0,400,800)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];

UIImagePickerController is a UINavigationController. Just show it as a full screen modal view controller instead of in a popover.
UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
ipc.delegate = self;
ipc.sourceType = UIImagePickerControllerSourceTypeCamera;
ipc.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:ipc animated:YES completion:nil];
You only need to use a popover on the iPad for selecting images from the photo library. But the camera is allowed to be shown full screen without a popover.

Related

Shift to UIPopoverPresentationController

I want to create the same popover for my iPhone app with size GGrect of (320 100.0).
Here is my old code:
View * pk1 = [[View alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:pk1];
pop = [[UIPopoverController alloc] initWithContentViewController:nav];
[pop setDelegate:self];
[pop presentPopoverFromRect:[self btnsavepart].frame inView:[self view] permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[nav release];
I using this codes but its doesn't change
nav.preferredContentSize = CGSizeMake(320, 100);
I can not change UIpopovercontriller with UIPopoverPresentationController.
How do I specify GGrect of (320 100.0)?
i thinks i can change only on horizontally but how can i do.
View *viewController = [[[View alloc] init] autorelease];
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:viewController] autorelease];
navController.modalPresentationStyle = UIModalPresentationPopover;
navController.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
navController.popoverPresentationController.sourceRect = btnsavepart.bounds;
navController.popoverPresentationController.sourceView = btnsavepart;
navController.popoverPresentationController.delegate = self;
[self presentViewController:navController animated:YES completion:nil];
i want the UIPopoverPresentationController not FullScreen form in iPhone
i adding this codes but i give the FullScreen view
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
{
return NO;
}
I work with Xamarin but its same thing , to specify size of the popover in which you want to display your UIViewController, in the properties of your UIVIewController you have the PreferredContentSize property. There you specify the size.
I saw it somewhere here but forgot where.

UIImagePickerControllerCameraCaptureModePhoto not working in IOS 7

In IOS6 I am using following method to get photo from I Pad photo Library.But now its not working for IOS7
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerCameraCaptureModePhoto;
picker.delegate = self;
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
[popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
[picker release], picker = nil;
What is issue with IOS7
Here you can use custom Frame and load the popover ;)
[popOver presentPopoverFromRect:CGRectMake(self.view.frame.size.width-50, 50, 10, 10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Check out UIImagePickerController crash only on iOS 7 - iPad
Its Probably an iOS 7 Bug. Probably your personal hotspot is on at the moment try to turn it off at and run the application

How to change the size width of UIImagePickerController on iPad?

How to change the size width of UIImagePickerController on iPad? I can change the height so it is 700 but can't change width and it still 320.
My code.
UIImagePickerController* imagePicker=[[UIImagePickerController alloc]init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.delegate=self;
CGRect myRect = CGRectMake(imagePicker.view.frame.origin.x, imagePicker.view.frame.origin.y, 720, 700);
imagePicker.view.frame = myRect;
self.popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
myRect = CGRectMake(100, 880, 900, 900);
CGRect re2 = CGRectMake(0,0,800,800);
[self.popover setPopoverContentSize:re2.size];
[self.popover presentPopoverFromRect:[self.view bounds] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[self.popover presentPopoverFromRect:myRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[self.popover setPopoverContentSize:re2.size];
I had your same problem and I solved with the UINavigationControllerDelegate, since the UIImagePickerView content for the PhotoLibrary is a navigatorController. When you select a row it changes ViewController and the size of the popover changes as well.
So, in your willShowViewController delegate just put:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
viewController.contentSizeForViewInPopover = CGSizeMake(800, 800);
}
This will prevent the resizing of the popover.
This simplified code worked fine for me:
UIImagePickerController* imagePicker=[[UIImagePickerController alloc]init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self.popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[self.popover presentPopoverFromRect:CGRectMake(100, 880, 1, 1) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[self.popover setPopoverContentSize:CGSizeMake(700, 700)];
iOS 9 and above.
Another way is it to use ContainerViewController and add UImagePickerViewController to ContainerViewController. overriding size in UINavigationControllerDelegate methods has its limits. (not possible to go down on height below 600pt)
_imagePicker = [[UIImagePickerController alloc] init];
_imagePicker.delegate = self;
_imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
_imagePicker.preferredContentSize = CGSizeMake(320, 480);
UIViewController *containerViewController = [[UIViewController alloc] init];
containerViewController.preferredContentSize = _imagePicker.preferredContentSize;
[containerViewController addChildViewController:_imagePicker];
[containerViewController.view addSubview:_imagePicker.view];
[_imagePicker didMoveToParentViewController:containerViewController];
if (!_imagePickerPopover) {
//customize PopoverController, use your own
_imagePickerPopover = [[PopoverController alloc] init:cnt];
}

Launching camera from modal view causes unwanted resize on iPad

In my iPad app I create and resize a modal view like this:
ModalViewController *modalController = [[WishlistInfoViewController alloc] initWithNibName:#"WishlistInfoViewController" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:modalController];
navController.modalPresentationStyle = UIModalPresentationPageSheet;
self presentViewController:navController animated:YES completion:nil];
navController.view.superview.bounds = CGRectMake(0, 0, 700, 700);
navController.view.superview.center = CGPointMake(self.view.center.x, self.view.center.y + 35);
Inside that modal view I launch the camera like this:
UIImagePickerController *mypicker = [[UIImagePickerController alloc] init];
mypicker.delegate = self;
mypicker.allowsEditing = NO;
mypicker.sourceType = UIImagePickerControllerSourceTypeCamera;
mypicker.showsCameraControls = YES;
mypicker.wantsFullScreenLayout = YES;
[self.navigationController presentModalViewController:mypicker animated:YES];
I dismiss the camera like this:
[self dismissModalViewControllerAnimated:TRUE];
The problem is that when I dismiss the camera the modal view is resized to fill the whole screen. What can I do to prevent the modal view from resizing?
Ok, so I fixed my issue but just resetting the size of the view right after calling [self dismissModalViewControllerAnimated:YES];. I don't know why I didn't try this until now.

image picker appears momentarily on IPad

I have the following code:
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
popover = [[UIPopoverController alloc] initWithContentViewController:picker];
popover.delegate = self;
[popover presentPopoverFromRect:self.view.frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
[picker release];
It should place an image picker dialog on screen in IPad. It works OK on simulator, but on device the picker appears momentarily and disappears.
Any ideas how to fix?
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
self.popoverController = popover;
popoverController.delegate = self;
[self.popoverController presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
[picker release];