UIImagePickerController不尊重iPad上的视频最长持续时间

时间:2013-06-28 23:51:50

标签: ios objective-c ipad uiimagepickercontroller

我正在尝试构建一个应用程序,让用户从iPad上的库中挑选和上传视频。我需要最大视频长度为30秒。

我使用以下代码:

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];

在挑选视频后,我希望UIImagePickerController显示一个修剪器,将视频长度调整为30秒(如果更长),但事实并非如此。

1 个答案:

答案 0 :(得分:14)

在呈现控制器之前设置此项。

imagePickerController.allowsEditing = YES;