2011-06-15 74 views
1

我試圖將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是一個屬性。這是否意味着我需要自己創建該屬性,還是位於某處? '因爲相機的作品,如果我不做任何代碼,但閃光燈模式設置爲自動...

顯然有一些我不明白。 :/

回答

10


picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;

+0

在該行仍然得到一個SIGABRT更換picker.cameraDevice = UIImagePickerControllerCameraFlashModeOff:/ – Jambaman 2011-06-15 17:49:35

+0

當然,我必須設置委託給自己後,它寫的...就像一個魅力!謝謝! – Jambaman 2011-06-15 17:53:09

+0

只是爲了檢查,你是在4.0 +版本上運行? – Tatvamasi 2011-06-15 17:54:26