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;
Related
My Storyboard contains a CameraViewController in which I designed my custom overlay view.
As long as I use it as one tab of my UITabbarController, the cameraOverlayView is visible. But if I segue to this view controller from any other VC, the overlay view is visible only for a fraction of a second, then only the preview image is visible.
#implementation CameraViewController
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
UIImagePickerController *picker = [UIImagePickerController new];
if (![UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) return;
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = NO;
picker.allowsEditing = NO;
picker.cameraOverlayView = self.view;
[self presentViewController:picker animated:YES completion:nil];
}
I have tried any segue types, presentation styles, etc., the problem stays the same.
I inserted some logs in viewDidDisappear, and noticed that this function in fact is called, I guess that's the reason why the overlay disappears.
Keep in mind: If I just open the tab of my Tabbarcontroller, everything just works fine! The problem only occurs if I segue to the CameraVC.
Thanks in advance!
The solution is to select modal presentation style and "Over current context", because then the viewDidDisappear event is not triggered.
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 am using an imagePicker with a custom overylay view, which has a button for the photo library, among other things. I am instantiating it like this:
_overlay = [[CameraWithOverlayViewController alloc]initWithNibName:#"OverlayView" bundle:nil];
_overlay.delegate = self;
_imagePicker = [[UIImagePickerController alloc] init];
_imagePicker.delegate = self;
_imagePicker.allowsEditing = NO;
_imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
_imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
_imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
_imagePicker.modalPresentationStyle = UIModalPresentationCurrentContext;
_imagePicker.showsCameraControls = NO;
_imagePicker.navigationBarHidden = YES;
_imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
_imagePicker.cameraOverlayView = _overlay.view;
and presenting modally. The CameraWithOverlayViewController reports overlay button presses back to me via a delegate protocol, which I then use to take the photo, switch to the photo library, or cancel out of the imagePicker.
When the user clicks the photo library button, I am running this:
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
to bring up the photo library instead of the camera.
Problem one is that when you use a custom camera overlay view, the imagePicker.allowsEditing boolean property is bypassed, which means I had to build my own cropping view. But the photo library is sending me to the cropping view even with imagePicker.allowsEditing = NO set.
The second problem is that, despite having set myself as the imagePicker's delegate, and implementing the delegate protocol/methods, the cancel button on the photo library's view is not calling - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker, so I cannot use that method to put a user back on the camera screen if they cancel from the photo library.
Any insight would be much appreciated!
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.
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...