I have to give functionality to select photos by the user. I have used this:
ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
Now I have to restrict user to select only photos and i want videos to be not displayed on the list. Or somehow user should not select video at all. How to achieve that?
basically what you're trying to do is to set the "media types". and luckily for you imagePicker has a property just for that called "mediaTypes". :) which receives an array of media types to show for selection.
even luckily-er this is the default behaviour of ImagePicker is to show only image types.
but if you really want to make sure you can do this:
[imagePicker setMediaTypes: [NSArray arrayWithObject:kUTTypeImage]];
and don't forget to add at the top of the file... :)
#import <MobileCoreServices/UTCoreTypes.h>
but really, i think we can trust apple when they say it's they're default behavior... :)
You will get a compiler warning about incompatible pointer types (at least in XCode 4) when adding kUTTypeImage to an NSArray. However, kUTTypeImage is a CFStringRef, and according to the CFString documentation, a CFStringRef is compatible with NSString *. Therefore, to make the compiler happy, cast kUTTypeImage to an NSString *:
picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With