开发者

Setting flash mode to off as default

开发者 https://www.devze.com 2023-03-13 01:28 出处:网络
I\'m trying to set the camera flash mode in an UIImagePickerController to off, but I don\'开发者_JAVA技巧t understand the reference page. Here is my code:

I'm trying to set the camera flash mode in an UIImagePickerController to off, but I don'开发者_JAVA技巧t understand the reference page. Here is my code:

- (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];
}}

I've tried setting picker.cameraDevice = UIImagePickerControllerCameraFlashModeOff, but this results in an error. The reference page says that cameraDevice is a property. Does this mean that I need to create that property myself, or is it located somewhere? 'Cause the camera works if I don't do anything to the code, but with flash mode set to auto...

There is obviously something I haven't understood. :/


replace picker.cameraDevice = UIImagePickerControllerCameraFlashModeOff with
picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号