2011-03-16 84 views
1

我有問題。我使用以下代碼在iOS 4.x設備上啓動攝像頭並錄製視頻,效果很好。我想在iPad 2設備上使用相同的代碼,因爲iPad 2具有視頻錄製功能。它會起作用嗎?有人能指導我嗎?以編程方式啓動攝像機進行視頻錄製

if ([types containsObject:(id)kUTTypeMovie]) 
{ 
    UIImagePickerController *pickerController = [[[UIImagePickerController alloc] init] autorelease]; 
    pickerController.delegate = self; 
    pickerController.videoQuality = appDelegate.settingsCtrler.quality; 
    pickerController.sourceType = UIImagePickerControllerSourceTypeCamera; 
    pickerController.showsCameraControls = YES; 
    pickerController.mediaTypes = [NSArray arrayWithObject:(id)kUTTypeMovie]; 
    pickerController.videoMaximumDuration = maxDuration; 
    [appDelegate hideFloatingBar]; 
    [self presentModalViewController:pickerController animated:YES]; 
} 

先謝謝您了!

回答

1

如果它建立在iOS 4.3上,您應該可以 - 雖然我沒有iPad2來測試它。我想包的邏輯雖然測試:

if([picker isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { 
    // Your code here. 
} 

所以它不會試圖呈現相機時,一個不可用。

+0

太棒了!謝謝。所以,正如你所說,我只需要與iOS 4.3 SDK與相同的代碼應該正常工作? – Getsy 2011-03-16 18:40:25

相關問題