PhotoLibrary/Camera does not activate on in iPhone app - iphone

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];?

Related

UIImagePickerControllerSourceTypePhotoLibrary in iOS 7 is not Working

When I upgraded to iOS7, my app is showing an empty view controller when I access the photo Library from the application. It was working with older frameworks.
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.delegate = self;
self.imagePicker = imagePickerController;
//self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:self.imagePicker animated:YES completion:nil];
Please apply direct this code
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.delegate = self;
[self presentViewController:imagePickerController animated:YES completion:nil];
when this code run then "application" Would like to access your photos message come when you click on OK then all images will be displayed
Thanks.

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];
}

objective c Take picture in Camera API Phone Gap

I am working in phonegap Camera API new to objective c i dont know how to declare method and interface for this function in .h file
if([(NSString *) [components objectAtIndex:1] isEqualToString:#"Take_Photo"])
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsImageEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
}
I've declared UIImagePickerControllerDelegate in .h file but the camera is not opening.
i did not get any error when i debugging the application paused after completed the line
[self presentModalViewController:picker animated:YES];
the application debugger paused in the binary file. i think i missed something in .h file.
#interface NativeAPI :UIViewController
<UIWebViewDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate>
{
Reachability* internetReachable;
Reachability* hostReachable;
UIImagePickerController* Image_Picker;
}
any one help me thanks in advance
You will be required to assign the value of the picker to the instance variable like this.
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
self.Image_picker = picker;
[picker release];
Image_picker.delegate = self;
Image_picker.allowsImageEditing = YES;
Image_picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
Try the code above
You can define a method under the implementation which is to be called by the delegate.

Getting memory leaks when using camera integration code in iphone

I'm doing an application which allows user to take a picture from camera or select picture from library.
I'm using the code
- (BOOL)startCameraPickerFromViewController:(UIViewController*)controller usingDelegate:(id<UIImagePickerControllerDelegate>)delegateObject
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *picker = [[[UIImagePickerController alloc] init]autorelease];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.allowsImageEditing = YES;
picker.delegate = self;
[controller presentModalViewController:picker animated:YES];
}
return YES;
}
I'm getting memory leak when I'm running this application. I'm running this application on 3.0.
Guys Please help me.
After [controller presentModalViewController:picker animated:YES]; do [picker release]; and get rid of the autorelease when you init the UIImagePickerController. That may work?

dismiss ModalViewController from another viewcontroller in 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.