2011-06-28 160 views
3

在此先感謝。 我想創建一個自定義相機view.Like這enter image description here在iphone中自定義相機視圖

要在一個視圖控制器爲此,我已創建的另一個視圖控制器的實例,並在第二視圖 - 控制我創建的UIImagePickerController這樣的觀點:

-(void)showCamera 
{ 
camController = [[UIImagePickerController alloc]init]; 
    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) 
    { 
     camController.sourceType = UIImagePickerControllerSourceTypeCamera; 
    } 
    camController.showsCameraControls = NO; 
    camController.navigationBarHidden = YES; 
    camController.toolbarHidden = YES; 
    camController.wantsFullScreenLayout = NO; 
    camController.cameraViewTransform = CGAffineTransformScale(camController.cameraViewTransform, 2.0f, 2.0f); 
// Edited 
//[self presentModalViewController:camController animated:YES]; 

} 

和在第一視圖中的控制器:

cam = [[CamController alloc]init]; 
cam.view.frame = CGRectMake(5, 50, 310, 300) ; 
[cam showCamera]; 
[self.view addSubview:cam.view]; 
//Edited 
[self.cam presentModalViewController:self.cam.camController animated:NO]; 
[self performSelector:@selector(setFrame) withObject:self afterDelay:1.0]; 
[self.cam.camController.view setFrame:CGRectMake(10, 50, 300, 250)]; 

這是不實際工作。這是正確的過程。誰能幫我 。

+1

你能指定「不工作」的本質嗎? – Caleb

+0

@Caleb:感謝你的回覆。不工作意味着它不顯示任何東西。 –

+0

@sandhya其實我正在做這種類型的項目,所以你已經完成了這個項目。請幫我 –

回答

2

sandhya,UIImagePickerController有一個名爲cameraOverlayView屬性的內置函數。

你可以ALLOC的觀點,然後有

UIImagePicker *camPicker; // alloc camera picker here bla bla bla 
CameraView *camview = [[CameraView alloc] initWithNibName:@"CameraView" bundle:nil]; 
camPicker.cameraOverlayView = camview.view; 
camPicker.showsCameraControls = NO; 

曬。

+0

我可以通過修改顯示的像素來修改它。像扭曲他們和所有。就像我們在Mac上的Photobooth一樣? –

相關問題