2011-06-16 96 views
0

我正在使用以下代碼在iPhone上啓動靜態攝像機。iOS SDK:啓動攝像機(攝像機),而不是靜止攝像機

UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 
picker.sourceType = UIImagePickerControllerSourceTypeCamera; 
picker.delegate = self; 
[self presentModalViewController:picker animated:YES]; 
[picker release]; 

我想知道如何才能啓動只有攝像機,而不是相機。我需要this view沒有在右下角的開關。

任何想法?

回答

8

您必須添加這兩行才能在攝像機模式下啓動。

picker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera]; 
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo; 

您還可以將其限制爲視頻模式並通過僅啓用適當的媒體類型來隱藏開關。這樣做是爲了只允許視頻模式,

picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie]; 

你不過需要添加MobileCoreServices.framework,這和#import <MobileCoreServices/MobileCoreServices.h>

+0

@丹科米爾是這個解決的嗎? – 2011-06-19 18:05:38

2

嘗試增加

picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;