问题
I am trying to build an app that would let user pick and upload a video from the library on iPad. I need the max video length to be 30 sec.
I am using the following code:
UIImagePickerController *mediaPicker = [[UIImagePickerController alloc] init];
mediaPicker.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeMovie,(NSString *)kUTTypeImage,nil];
mediaPicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
mediaPicker.videoQuality = UIImagePickerControllerQualityTypeIFrame960x540;
mediaPicker.videoMaximumDuration = 30.0f;
mediaPicker.delegate = self;
if (self.imagePickerPopOverController.popoverVisible) {
[self.imagePickerPopOverController dismissPopoverAnimated:YES];
}
self.imagePickerPopOverController = [[UIPopoverController alloc] initWithContentViewController:mediaPicker];
[self.imagePickerPopOverController presentPopoverFromBarButtonItem:self.navigationItem.rightBarButtonItem
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:NO];
After the video has been picked, I expect the UIImagePickerController to show a trimmer to trim the video length to 30 sec (if its longer), but it does not.
回答1:
Set this before you present the controller.
imagePickerController.allowsEditing = YES;
来源:https://stackoverflow.com/questions/17375249/uiimagepickercontroller-not-respecting-video-maximum-duration-on-ipad