How can I hide the picture preview? - iphone

I am new in iPhone development,
I have built new app to take a picture using UIImagePickerController.
Everything is work fine with me, but I need to dismiss the picture preview that appear after I press the capture button.
I search through the net then I found I must use the following routine.
(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo
{
[self dismissModalViewControllerAnimated:YES];
}
but it didn't work.
Any help or suggestions, is highly appreciated.

You need to add your own camera overlay view. This view should have a button on to Take a picture.
To add an overlay view, create a view with a background colour of clear, then assign your overlay view to the picker control
self.imagePickerController.showsCameraControls = NO;
self.imagePickerController.cameraOverlayView = myOverlayView;
Then in your overlay view button event you call the following:
[imagePickerController takePicture];
This will then fire the following method on the imagePickerDelegate, and you can save your photo etc in there
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

Related

Image Picker Controller

I am using the UIImagePickerController to take a picture, that works great, but do not want to use the stand image editor, instead I want to use my own custom image editor. I want to transition to that after I take the picture. I am using the method below to push a view controller after the image picker dismisses.
However, I want to push this before the image picker dismiss to avoid an awkward transition. Any ideas?
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info;
The image picker is already in a navigation interface, so you can push anything you like onto the image picker as a secondary (editing) interface:
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage* im = info[UIImagePickerControllerOriginalImage];
if (!im)
return;
SecondViewController* svc =
[[SecondViewController alloc] initWithNibName:nil bundle:nil image:im];
[picker pushViewController:svc animated:YES];
}
You will, however, have to interfere to prevent the image picker from navigating to its own secondary interface. The easy way to do that is to set picker.showsCameraControls = NO and substitute your own controls.
Also, I might be wrong about this, but since you are the navigation controller delegate I think you can just veto an attempt by the image picker to navigate to its own secondary interface. (EDIT: No, I guess not, sorry. The delegate gets a will and a did but not a should message.)

How to reuse camera after take a photo?

I have a simple question: how to use (show) again a camera after take a photo?
I use UIImagePickeController and when the photo was taken (Use button was tapped) we go to delegate:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
How to tell camera to appears one again?

How to use the picture takes from camera?

Iam developing one application.In that i want to take the picture from camera.For that i used the UIImagePickerControllerSourceTypeCamera.But my problem is how to get that image intomy application.Please tell me how to manage that one.
Thats pretty simple. You have a method in UIImagePickerController which is
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImageWithMediaInfo(NSDictionary *)info. You can get here the image user had selected from UIImagePickerControllerSourceTypeCamera. Now declare an object of UIImage in the header of your AppDelegate. For example I declare UIImage *pickedImage. The purpose to declare this in AppDelegate is that we can use this Image anywhere in our app. Dont retain and synthesize this object. Now come back to your didFinishPickingImage method and now your body of this method should look like this:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)info {
((AppDelegate*)[UIApplication sharedApplication].delegate).pickedImage= [info objectForKey: UIImagePickerControllerOriginalImage];
}
Now you can easily use this image all over your app by just calling ((AppDelegate*)[UIApplication sharedApplication].delegate).pickedImage. Hope it helps.
Happy Coding!

UIImagePickerController: Detecting Camera button (shutter) pressed

I would like to call a method that takes an NSNotification immediately after the user presses the camera shutter (i.e when the "Preview" tab bar has the buttons "Retake" and "Use").
I can't use the didFinishPickingImage method because at this time the user has already pressed the "Use" button.
I have already implemented this by cameraOverlayView property of UIImagePickerController(see comments), but I wonder whether there are quicker ways of 'observing' this action.
Any ideas?
To learn about camera button press event, you can fire a NSNotification for it.
// Add observer for when camera button is pressed
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(yourFunctionToPerform), name: "_UIImagePickerControllerUserDidCaptureItem", object: nil)
Also add the following method to the ViewController where you are creating ImagePickerViewController:
-(void) yourFunctionToPerform{
//Do what you want to do on Camera button tap event
}
I was searching for this problem too, the key/name for the event is really obscure.
You CAN display it AFTER they choose the image.
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
//Display the UIAlertView
[alertView show];
//Just never use the image
}
If you don't want to use the image you really don't have to

UIImagePickerController in iPhone OS 3.0

I am using iPhone OS 3.0 SDK.
My requirement is that I want to get the image from the photo albums library and display it on an image view.
I am using the UIImagePickerController for that.
But the problem is the - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)imageeditingInfo:(NSDictionary *)editingInfo delegate method is deprecated in iPhone OS 3.0 ,
Is there any alternative for getting the Image from the UIImagePickerController.
All suggestions are highly appreciated.
Thanks...
use this delegate method of UIImagePickerController in your implementation file.
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
imageView.image = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
}
and don't forget to modify your header file with these two protocols
#interface photoAppViewController : UIViewController < UIImagePickerControllerDelegate,UINavigationControllerDelegate >
Speaking of 3.0 here would break your and my NDA with Apple. However I can suggest that you look at the relevant header files (mdfind didFinishPickingImage | grep 3.0 will find what you need quickly).
Some one posted me the answer as below.
In UIImagePickerController.h you can see that there ist a method you
can use:
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info;
The documentation does not show this method it is only in the .h file.
but I am still not getting the above method in the .h file