Refer to Apple's "Camera Programming Topics for iOS". The recommendation there is to implement imagePickerController:didFinishPickingMediaWithInfo:
instead of imagePickerController:didFinishPickingImage:editingInfo:
(which has been deprecated since iOS 3). Then, one can inspect the value of the info dictionary's UIImagePickerControllerMediaType
key and compare against the appropriate types.
For example (note that you'll need to add the MobileCoreServices framework, and import its header):
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *pickedMediaType = info[UIImagePickerControllerMediaType];
NSString *movieType = (__bridge NSString *)kUTTypeMovie;
NSString *imageType = (__bridge NSString *)kUTTypeImage;
if ([pickedMediaType isEqualToString:movieType]) {
NSLog(@"movie was picked");
}
else if ([pickedMediaType isEqualToString:imageType]) {
NSLog(@"image was picked");
}
else {
NSLog(@"something else was picked");
}
[self dismissViewControllerAnimated:YES completion:nil];
}
In your application, you'd replace the logging statements with the appropriate actions (From your question, it sounds like you already have code to push to the new view controllers, so replace the logging statements accordingly). Also, note that you generally shouldn't compare Objective-C objects with ==
. As I'm comparing strings, I use isEqualToString:
.