videoMaximumDuration不限制持续时间

时间:2012-04-25 18:05:07

标签: ios objective-c video uiimagepickercontroller

我希望用户从他的图书馆中挑选视频并将其限制为45秒(如WhatsApp - 您可以编辑视频,并且将发送的视频不会超过45秒。

但如果我使用下面的代码,无论持续时间如何,它都会选择一个视频,我无法修剪它(用视频测试,长度为1分钟)

UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
        imagePickerController.delegate = self; 
        imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        imagePickerController.videoQuality = UIImagePickerControllerQualityTypeLow;
        imagePickerController.videoMaximumDuration = 45.0f; //?
        imagePickerController.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];

        [[self parentViewController] presentModalViewController:imagePickerController animated:YES];
        [imagePickerController release];

在WhatsApp中,我得到以下屏幕,我想重现: enter image description here

1 个答案:

答案 0 :(得分:15)

确保在呈现控制器之前将allowsEditing设置为YES。

uiimagePickerController.allowsEditing = YES;