2013-08-05 86 views

回答

0

這可能對你有幫助。

-(IBAction)loadCameraView:(id)sender 
{ 

    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) 
    { 
     UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; 
     [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera]; 

if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]) 

    { 
     [imagePicker setCameraDevice:UIImagePickerControllerCameraDeviceFront]; 

    } 
    else 
    { 
     [imagePicker setCameraDevice:UIImagePickerControllerCameraDeviceRear]; 

    } 
    [imagePicker setCameraCaptureMode:UIImagePickerControllerCameraCaptureModePhoto]; 
    [imagePicker setDelegate:self]; 
    [self presentViewController:imagePicker animated:YES completion:nil]; 
} 
else 
{ 
    UIAlertView *aview = [[UIAlertView alloc] initWithTitle:@"Camera Not Available" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; 
    [aview show]; 
} 
} 
+0

此答案僅顯示如何呈現相機視圖。 –

2

UIImagePickerControllercameraOverlayViewUIView屬性。將它分配給任何你想要在相機上面的任何東西。

從文檔:

您可以使用覆蓋圖呈現在默認圖像挑選器界面的頂部自定義視圖層次結構。圖像選擇器將您的自定義疊加視圖疊加在其他圖像選擇器視圖的頂部,並將其相對於屏幕座標進行定位。如果您將默認相機控件設置爲可見,請將透明度合併到您的視圖中,或將其定位以避免模糊底層內容。

相關問題