Skip to content

Instantly share code, notes, and snippets.

@pratikshabhisikar
Created March 23, 2012 10:58
Show Gist options
  • Save pratikshabhisikar/2169599 to your computer and use it in GitHub Desktop.
Save pratikshabhisikar/2169599 to your computer and use it in GitHub Desktop.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) {
// Start video recording.
BOOL cameraAvailable = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
if (cameraAvailable) {
NSArray *availableMediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
BOOL videoRecordingAvailable = [availableMediaTypes containsObject:(__bridge id) kUTTypeMovie];
if (videoRecordingAvailable) {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = availableMediaTypes;
imagePicker.cameraViewTransform = CGAffineTransformMakeScale(2.0f, 2.0f);
imagePicker.delegate = self;
[self presentViewController:imagePicker animated:YES completion:^{
NSLog(@"Video recording started");
}];
}else {
// Optionally display error here...
NSLog(@"Video Recording not available");
}
}else {
// Optionally display error here...
NSLog(@"Camera not available");
}
}else if (indexPath.row == 1) {
// Push to list of recorded movies.
MoviesViewController *moviesController = [[MoviesViewController alloc] initWithStyle:UITableViewStylePlain];
[self.navigationController pushViewController:moviesController animated:YES];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment