How to reuse camera after take a photo? - iphone

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?

Related

URL for video selected from camera roll

I am able to launch camera roll from my app. I want to get the URL of the video when it is selected by a user, because I want to use it for asset reading/writing.
Is it possible to get the URL of the selected video from camera roll ? If yes, how ?
Thanks.
Set the UIImagePickerControllerDelegate to your class and use this code to retrieve the url.
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
[self dismissModalViewControllerAnimated:YES];
NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];
}
This is a good resource:Accessing the Camera and Photo Library from an iOS 4 iPhone Application

iPhone: How to find the duration of the album video?

I am picking video from photo album programmatically. I don't have any issues on that. I am able to retrieve the video path etc from the following delegate method.
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
But, i want to find out the duration of the video here. Is it possible to find out the duration of that video which i have chosen from photo album?
Please advise!
Thank you!

How can I hide the picture preview?

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

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!

copy video from iphone using the UIImagePickerController?

Hey, I know that when a user selects a Video I do get a URL for the video.... but can you direct me to a proper implementation because my App just sticks there when I click choose in the simulator and I cannot navigate away from the Video Player page....
Any good tutorial on this?
Once you select the video - execution flows to the following function:
(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
.... code here .....
//get the videoURL
NSString* videoURL= [info objectForKey:UIImagePickerControllerMediaURL];
//IMPORTANT: remember to test that the video is compatible for saving to the photos album
UISaveVideoAtPathToSavedPhotosAlbum(videoURL, self, #selector(video:didFinishSavingWithError:contextInfo:), nil);
.... code here .....
}
Take a look into 'UISaveVideoAtPathToSavedPhotosAlbum' specifically. This allows saving to the camera roll.