使用UIImagePickerController记录video

我正在开发一个记录video的iPhone应用程序。 我创建了一个UIImagePickerController ,将其限制为video录制,然后以编程方式请求摄像头启动VideoCapture。 不幸的是,当我运行应用程序时,我在控制台中得到以下内容;

 "UIImagePickerController: ignoring request to start video capture; camera is not yet ready." 

我怎么处理这个?

最可能的原因似乎是info.plist文件中缺少必需的密钥。 您需要配置UIRequiredDeviceCapabilities 。 此外,您必须实现委托对象。 有关详细信息,请查看http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/CameraAndPhotoLib_TopicsForIOS/Articles/TakingPicturesAndMovies.html#//apple_ref/doc/uid/TP40010406 。

HTH,

阿克沙伊

没有委托回调可以告诉您相机何时准备就绪。 我试过这个,但没有运气,仍然是你的错误:

 if ([UIImagePickerController isCameraDeviceAvailable:[picker cameraDevice]]) { [picker takePicture]; } else { NSLog(@"Camera not ready"); } 

我在延迟1.0,1.5,2.0秒后打电话给拍照。 我的观察:

在1.0秒时:拍摄照片但屏幕上没有看到完全快门关闭1.5秒:看到快门关闭但很少在2.0秒:加载相机,在屏幕上显示什么然后拍照。

所以你可能想要使用介于1.75到2.25之间的东西。 我使用的代码:

 [picker performSelector:@selector(takePicture) withObject:nil afterDelay:2.0];