user3587934
user3587934

Reputation: 51

How to Check whether camera is open for capture image or to record video in iOS?

In my app, Application allow user to capture image/record video. But I don't know how to check the result in below method.

- (void) imagePickerController: (UIImagePickerController *) picker
 didFinishPickingMediaWithInfo: (NSDictionary *) info {
}

Your solutions are always appreciated.Thanks in advance.

Upvotes: 0

Views: 638

Answers (1)

Mehul Patel
Mehul Patel

Reputation: 23053

Here what you need:

 - (void) imagePickerController: (UIImagePickerController *) picker
 didFinishPickingMediaWithInfo: (NSDictionary *) info {
    NSString *mediaType = info[UIImagePickerControllerMediaType];

    if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
        // Media is an image

        UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

    }
    else if ([mediaType isEqualToString:(NSString *)kUTTypeVideo] || [mediaType isEqualToString:(NSString *)kUTTypeMovie])
    {
        // Media is a video
        // Video URL
        NSURL *localUrl = (NSURL *)[info valueForKey:UIImagePickerControllerMediaURL];
    }
}

Upvotes: 2

Related Questions