我正在尝试将UIImagePickerController中的相机闪光模式设置为关闭,但我不明白the reference page。这是我的代码:
- (void)getMediaFromSource:(UIImagePickerControllerSourceType)sourceType {
NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:sourceType];
if ([UIImagePickerController isSourceTypeAvailable:
sourceType] && [mediaTypes count] > 0) {
NSArray *mediaTypes = [UIImagePickerController
availableMediaTypesForSourceType:sourceType];
mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, nil];
UIImagePickerController *picker =
[[UIImagePickerController alloc] init];
UIImagePickerControllerCameraDevice *device;
picker.mediaTypes = mediaTypes;
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = sourceType;
[self presentModalViewController:picker animated:YES];
[picker release];
}}
我尝试过设置picker.cameraDevice = UIImagePickerControllerCameraFlashModeOff,但这会导致错误。参考页面说cameraDevice是一个属性。这是否意味着我需要自己创建该属性,还是位于某处? '如果我对代码没有任何操作,但闪光模式设置为自动...
,则相机会工作显然有一些我不理解的东西。 :/
答案 0 :(得分:10)
用{替换picker.cameraDevice = UIImagePickerControllerCameraFlashModeOff
picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;