Get date created of video from UIPickerViewController - Swift - swift

If you present a UIImagePickerController with a source type of .camera or .photoLibrary (Swift), how can you get the date taken in UIImagePickerControllerDelegate.

You can use this (YPImagePicker) pod for get videos detail.

Related

UIImagePickerController - Let user choose between camera and album?

In my app I have the ability for the user to take a photo and post it to a web service. I use the following code:
imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .Camera
presentViewController(imagePicker, animated: true, completion: nil)
However, I would prefer to give the user the option to either take a photo with their camera or pick a photo from the album. I know I can choose sourceType = .PhotoLibrary but that again rules out the camera as a possible source. Is there no combination here that can give me both?
Thanks!
You can use a UIAlertController to present an alert with style UIAlertControllerStyle.ActionSheet, giving those both as choices.
This is like how Apple does it when you choose to add a photo to a text message in the Messages app, and is used in other apps as well to provide this choice, so this is obviously the most official method available for doing this. But you won't find a way to just present a UIImagePickerController that lets you choose.

UIImagePickerController CameraDevice picks wrong device every other time (using ARC)

My app takes a video (using a custom overlay, in case that's relevant) where I have the cameraDevice set to front facing camera. 3 videos need to be taken, though the cameraDevice alternates between front and rear each time the UIImpagePickerController is called to take the video. On each occasion the
picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
is used within the code, though as mentioned the app ignores this command every other time.
I see this problem has been asked before, though I am using ARC so the previously suggested solutions of releasing the UIImagePickerController is not an option for me.
Thanks in advance, Jim.
You cannot release the picker in ARC but you can still create a brand new one like this:
picker = nil;
picker = [[UIImagePickerController alloc] init];
// configure picker
Notice that in Apple's sample code "Using UIImagePickerController to Select Pictures and Take Photos" they call a method each time which does exactly this.

iPhone How to present photos from my documents directory?

I have been using UIImagePicker controller for taking photos and saving it to my documents directory. Now i want to be able to present them to user for picking. UIImagePicker has neat functionallity
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
When I set this property all images from library are presented. Is there some way I can use UIImagePicker to present my photos from documents directory?
The only supported sources for the UIImagePicker are library, camera or saved photo album. See UIImagePickerControllerSourceType # http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html
enum {
UIImagePickerControllerSourceTypePhotoLibrary,
UIImagePickerControllerSourceTypeCamera,
UIImagePickerControllerSourceTypeSavedPhotosAlbum
};
typedef NSUInteger UIImagePickerControllerSourceType;

What are the methods/classes I need to create an iPhone upload photo form?

Currently I have a view with an ImageViewer and 2 buttons (Browse & Upload). I'm currently searching for methods to display the iPhone photo album once the button is pressed.
I've looked at this example here but I assume this one is the method you call when you want to upload the photo into the server.
Objective C: How to upload image and text using HTTP POST?
I'd like to duplicate the functionality of a web upload form.
1. Click button to browse folders.
2. Choose photo and display in a container.
3. Click Upload to upload photo into the server.
**Update:
Found some nice tutorials that helped me start with my iPhone app photo upload form.
Using UIImagePickerController
http://iosdevelopertips.com/camera/camera-application-to-take-pictures-and-save-images-to-photo-album.html
http://trailsinthesand.com/picking-images-with-the-iphone-sdk-uiimagepickercontroller/
Adding images to iPhone Simulator
You will have to use UIImagePickerController class
Here is the class reference for UIImagePickerController
Initialize the picker controller in your button event handler method.
Then set the UIImagePickerControllerDelegate to your current viewController
Here is the class reference for UIImagePickerControllerDelegate
picker.delegate = self;
Set the UIImagePickerControllerSourceType of picker to UIImagePickerControllerSourceTypePhotoLibrary
picker.UIImagePickerControllerSourceType = UIImagePickerControllerSourceTypePhotoLibrary
Then present the pickerViewController (if your target device is an iPad, present the imagePickerView in a popOver control)
Once user selects an image picker controller will automatically call its delegate method
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
You can get the selected image by accessing the value for UIImagePickerControllerOriginalImage from the NSDictionary *info
Then you can use the image for uploading to server as mentioned in the post link
These are some tutorials for UIImagePickerController
Tutorial one
Tutorial two
Tutorial three
for getting images from iPhone library you have to use UIImagePickerController.
m_imagePickerController = [[UIImagePickerController alloc] init];
m_imagePickerController.delegate = self;
m_imagePickerController.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
hope this will help you

How to record video in iPhone using Objective-C?

I have a map application in which there is a button named video. If a user clicks on the video button he can record video at any location he like and simultaneously play the video.
How can I do this? My code is as follows:
-(IBAction)video:(id)sender { UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.delegate = self; NSArray *sourceTypes = [UIImagePickerController availableMediaTypesForSourceType:picker.sourceType]; if (![sourceTypes containsObject:(NSString *)kUTTypeMovie ]){ NSLog(#"device not supported"); return; } picker.sourceType = UIImagePickerControllerSourceTypeCamera; picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeVideo]; picker.videoQuality = UIImagePickerControllerQualityTypeHigh; [self presentModalViewController:picker animated:YES]; }
From Apple Programming guides
Starting in iPhone OS 3.0, you can
record video, with included audio, on
supported devices. To display the
video recording interface, create and
push a UIImagePickerController object,
just as for displaying the
still-camera interface.
To record video, you must first check that the camera source type
(UIImagePickerControllerSourceTypeCamera)
is available and that the movie media
type (kUTTypeMovie) is available for
the camera. Depending on the media
types you assign to the mediaTypes
property, the picker can directly
display the still camera or the video
camera, or a selection interface that
lets the user choose.
Using the UIImagePickerControllerDelegate
protocol, register as a delegate of
the image picker. Your delegate object
receives a completed video recording
by way of the
imagePickerController:didFinishPickingMediaWithInfo:
method.
On supported devices, you can also pick previously-recorded videos from a
user’s photo library.
For more information on using the image picker class, see
UIImagePickerController Class
Reference. For information on trimming
recorded videos, see
UIVideoEditorController Class
Reference and
UIVideoEditorControllerDelegate
Protocol Reference.
Once you have the video in your UIImagePickerController delegate you can then save it to your app's documents directory using standard file operations.