iOS4 UIImagePickerController不支持mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie]?

时间:2010-06-22 12:46:31

标签: ios ios4 mobilecoreservices

在我的应用程序中,我想以视频模式打开相机。所以我写下面的代码


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];

    UIImagePickerController *ipc;
    ipc = [[UIImagePickerController alloc] init];
    ipc.sourceType = UIImagePickerControllerSourceTypeCamera;
    ipc.mediaTypes = [NSArray arrayWithObject:(NSString *) kUTTypeMovie];

    [viewController presentModalViewController:ipc animated:YES];

    return YES;
}

此代码适用于iPhone 3.1.3,但在iOS4上不起作用。 我可以在iOS4上使用UIImagePickerController作为视频吗?

1 个答案:

答案 0 :(得分:3)

我是iphone开发的新手,但我有同样的问题,我解决了设置这样的mediaTypes的问题

NSArray* mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera]
ipc.mediaTypes = mediaTypes;

这允许您访问视频和照片,我希望这可以帮助您