I am working on an app using iOS 7. Sometimes I face a problem in iOS 6 device when i open the camera. It freezes on camera shutter. Although I set ARC to YES. I couldn't understand where is the problem?
I used the code for this
self.cameraUI = [[UIImagePickerController alloc] init];
self.cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
self.cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
self.cameraUI.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.cameraUI.navigationBarHidden = YES;
self.cameraUI.showsCameraControls = NO;
self.cameraUI.wantsFullScreenLayout = YES;
self.cameraUI.delegate = self;
[self.cameraView addSubview:self.cameraUI.view];
You shouldn't be doing addSubview: to a UIImagePickerController's view. Instead it is recommended to present the UIImagePickerController and implement its delegates to get the selected image.
From Apple docs for How to use UIImagePickerController?,
Present the user interface. On iPhone or iPod touch, do this modally (full-screen) by calling the presentViewController:animated:completion: method of the currently active view controller, passing your configured image picker controller as the new view controller.
This is how you can present it from your controller,
[viewcontrollerObj presentViewController:self.cameraUI animated:YES completion:nil];
Hope that helps!
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;
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...
UIImagePicker opening in Portraite mode while my app is in ladscape mode.
code for UIimage picker is
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:nil];
The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified, with one exception. You can assign a custom view to the cameraOverlayView property and use that view to present additional information or manage the interactions between the camera interface and your code.
Reference from Apple docs
I have an iPhone app that displays the camera using UIImagePicker to take a picture. I am porting it to iPad2 and when i want to display the camera (through a modalviewcontroller) i get the camera buttons but the display in the preview is just white. If i take the picture i can see it.
Does this happen to you?
I am experiencing the same problem. I moved the UIImagePicker code to my rootviewcontroller, and it worked. I could see what was actually through the viewfinder. It also worked via a popover in the existing viewcontroller (called next after the rootviewcontroller), but the resolution was poor when I displayed the photo. This is not satisfactory, but I guess I found a workaround if absolutely necessary.
Yesterday only i have tried this code to use camera to take pics. from my app and it worked on iphone after porting it.
I think you need to call takePicture method on the controller.
Just a guess.
if([UIImagePickerController isSourceTypeAvailable:sourceType])
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = sourceType;
picker.delegate = self;
if(sourceType == UIImagePickerControllerSourceTypeCamera)
[picker takePicture];
[self presentModalViewController:picker animated:YES];
[picker release];
}