我正在开发一个应用程序。我需要使用相机拍摄视频。所以请告诉我如何做这个。
问问题
103 次
3 回答
1
仔细阅读UIImagePickerController 类参考。它将告诉您如何解决您的问题。
于 2012-05-16T12:47:26.207 回答
0
我假设你知道如何使用UIImagePickerController
#import <MediaPlayer/MediaPlayer.h> // add MediaPlayer.framework
- (IBAction) startCamera
{
UIImagePickerController * startCamera;
startCamera = [[UIImagePickerController alloc] init];
startCamera.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
NSArray *mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
startCamera.mediaTypes = mediaTypes ;
startCamera.sourceType = UIImagePickerControllerSourceTypeCamera;
startCamera.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo ;
startCamera.allowsEditing = YES ;
}
else
{
startCamera.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
[self presentModalViewController:startCamera animated:YES];
[startCamera release];
}
于 2012-05-16T12:55:11.330 回答
0
试试这个代码片段。仅在设备中测试此代码。在 UIImagePickerDelegate 方法中处理录制的视频。
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
if (([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]))
{
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController: picker animated:YES];
}
else
{
NSLog(@"Put alert no camer found");
// Put alert no camer found
}
[picker release];
于 2012-05-16T12:58:10.770 回答