我可以通过编程方式打开 新iPhone 4设备上的 之前使用-takePicture
拍照吗?
我正在为iOS 4开发一款照片应用程序,并希望在用户拍照之前启动闪光灯 ,这样他们就可以提前看到闪光灯的效果。
问题似乎是要让闪光灯继续亮起,你需要设置torchMode
,这只能在'视频模式'(UIImagePickerControllerCameraCaptureModeVideo
)中进行,而你只有在{照片模式'(UIImagePickerController
)上时takePicture
UIImagePickerControllerCameraCaptureModePhoto
才能询问。
因此,以下情况有效,但仅在拍照时显示闪光灯:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = NO;
picker.navigationBarHidden = YES;
picker.toolbarHidden = YES;
picker.mediaTypes = [NSArray arrayWithObjects:@"public.image", nil];
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;
[self presentModalViewController:picker animated:YES];
这也有效(一直显示火炬),但后来我无法拍照。
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = NO;
picker.navigationBarHidden = YES;
picker.toolbarHidden = YES;
picker.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeMovie, nil];
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;
[self presentModalViewController:picker animated:YES];
当我尝试toggleTorch
代码时,UIImagePickerController
似乎没有UIImagePickerController
中的任何实时视频供稿。
这些AVCaptureSession
和torchMode
是否相互兼容?或者你应该选择其中一个?
是否有人知道解决方法是启用Flash模式(或takePicture
)并能够{{1}}?
答案 0 :(得分:1)
看看WWDC 2010会议(特别是409),他们将进入您正在寻找的功能。
如果你想要执行这些自定义相机功能并转向AVFoundation类,基本上你需要离开UIImagePickerController。