UIImagePickerController not respecting video maximum duration on iPad

放肆的年华 提交于 2020-03-02 05:29:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!