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.
Related
I trying to write some app with objective-c for iOS.
I have a project with tap bar controller.
In my last tap I've button click on this I will show camera.
So when I took my photo with camera, and tap on "Use photo", it's call ViewDidLoad of parent controller of my TapBarViewController, and my tap controller reload with changeative tap
I also tried to google
but there are no solutions..
thisand this doesn't work for me.
Please, what I do wrong?
My method witch call camera is:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:nil];
UPDT:
Also I think that it is not resource problem like described here
Ok, after one day of researching I found the solution.
after that I added this line it's work fine.
picker.modalPresentationStyle = UIModalPresentationCustom;
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];
}
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.
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 am working with camera in my application. Here are steps how I am working.
1) In MyViewController, I am opening an ActionSheet.
2) On tap a button in that Action sheet opening camera using following code
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.allowsEditing = YES;
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:picker animated:YES];
3) After taking a Photo and tapping on USE following code get executed
// I use the caputred photo
[ self dismissModalViewControllerAnimated:YES];
After this statement its calling "ViewDidLoad" of MyViewController, which is actually refreshing my screen, I dont want this behaviour.
This problem observed only on iOS 4.2
I am using ARC
Please help me if any one has already faced this issue...