dismiss ModalViewController from another viewcontroller in iPhone - iphone

The new 3.1 sdk allows for the UIImagepickerController to hide the camera controls and use your own controls via cameraOverlay view. So, I implemented the overlay view through another Viewcontroller:
CameraViewController *cameraController = [[CameraViewController alloc] initWithNibName:#"CameraViewController" bundle:nil];
self.cameraviewController = cameraController;
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.cameraOverlayView = cameraviewController.view;
picker.showsCameraControls = NO;
[self presentModalViewController:picker animated:YES];
[cameraController release];
[picker release];
The cameraviewController.view has the Cancel button. The problem I'm facing is how to dismiss the Modal view with that cancel button. I haven't found a way of referencing the controller which called the Modalview.
Many thanks in advance

need to add cameraController.delegate = self; and setup the delegate protocol in CameraViewController.

Related

Customising iphone cameraview(overlay)

My iPhone app allows the user to record videos.
How can I customize my camera view like in the screen shots.(also I need to make a custom timer-countDown)
You need to put all the custom elements in a UIView and assign that view to the cameraOverlayView property.
- (void)takePicture {
if (([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera] == NO)) return;
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
// add a custom view overlay
[imagePickerController setCameraOverlayView:customView];
[self presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];
}
See also http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html#//apple_ref/occ/instm/UIImagePickerController/cameraOverlayView

How to set Custom overlay view on Editing View of UIImagePickerController?

All
I have create UIImagePickerController with delegate and picking images from PhotoLibrary.
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
[self presentModalViewController:imagePicker animated:YES];
And when application reach to Editing view of UIImagePickerController i set one Overlay view and create two buttons for it.
Cancel and Choose
On Cancel Button click
[imagePicker popToViewController:[currentViewController.viewControllers objectAtIndex:1] animated:YES];
this cod work fine..
But choose Button does not working,
if i set code like here,
[self imagePickerController:imagePicker didFinishPickingMediaWithInfo:[imagePicker mediaTypes]];
than it returns NULL value of info dictionary.
Is that any other way to set overlay view on Editing ImagePicker ?
Regards,
try this code
CustomOverlayView *CustomOverlayView = [[CustomOverlayView alloc] initWithFrame:CGRectZero];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.allowsEditing = NO;
imagePickerController.delegate = self;
imagePickerController.showsCameraControls = YES;
[imagePickerController.view addSubview:CustomOverlayView];
[self presentModalViewController:imagePickerController animated:YES];
}

ARToolkit, UIImagePickerController & cameraOverlayView: How to take a picture?

I am developing an Augmented Reality app for iPhone with ARToolkit. Now I want to include its functionality in a main app, with a button which throws an 'AR View', in order to be able to take a picture with the 3D model on it.
I am using UIImagePickerController with cameraOverlayView to add the ARViewController view to the camera view, as an overlay, but it does not show it. Here it is the code:
-(IBAction)Switch2AR:(id)sender{
ARController = [[ARViewController alloc] init];
[ARController loadView];
UIImagePickerController *picker = [[UIImagePickerController alloc]init];
picker.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else {
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
picker.showsCameraControls = YES;
picker.cameraOverlayView = ARController.view;
//[ARController.view addSubview: picker.view];
//[picker.view addSubview: ARController.view];
//[picker viewWillAppear:YES];
//[picker viewDidAppear:YES];
//[ARController viewWillAppear:YES];
//[ARController viewDidAppear:YES];
[self presentModalViewController:picker animated:YES];
[ARController release];
}
I also tried to add the UIImagePickerController view as a subview of the ARViewController view, but does not work since the camera modal view 'hides' the AR view. Also ARViewController view as UIImagePickerController subview.
The problem is that I cannot overlay my ARView and the camera view in any way I tried
Thanks in advance
Just change
picker.showsCameraControls = YES;
to
picker.showsCameraControls = NO;
and it should work.

UIIMagePickerController don't automatically dismiss picker

How do you prevent the UIImagePickerController from automatically dismissing the camera after a picture is taken?
You set the picker to allowsImageEditing to be YES before you present it.
picker.allowsImageEditing = YES;
picker.delegate = self;
[self presentModalViewController:picker animated:YES];

PhotoLibrary/Camera does not activate on in iPhone app

I've this method for opening the photoLibrary/camera in my view controller. But nothing happens when I call it (both simulator and device). I've implemented the delegate methods. No errors/warnings. I'm missing something?
- (IBAction) doButton {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.allowsEditing = YES;
[self.navigationController presentModalViewController:picker animated:YES];
}
Should you not just call [self presentModalViewController:picker animated:YES];?