2012-02-06 72 views
1

我的問題; 隱藏默認的相機控制,並用我自己的覆蓋。這是與屬性cameraOverlayView。我也遇到了觸發takePicture方法的問題。在相機上拍照方法OverlayView

+0

只要繼續嘗試一下。如果遇到具體問題,請回到這裏。 – mvds 2012-02-06 11:07:11

+0

http://jcuz.wordpress.com/2010/02/17/pickerfocus/ – Sharme 2012-02-06 11:07:44

+0

[UIImagePickerController:自定義攝像頭疊加坐在默認控件之上?]的可能的重複?(http://stackoverflow.com/questions/5251336/ uiimagepickercontroller-custom-camera-overlay-sitting-on-default-control) – 2012-02-06 11:11:48

回答

0

(問題的意見,並在修改解決了見Question with no answers, but issue solved in the comments (or extended in chat)

的OP寫道:

這裏是走過來的解決方案:

我有兩個UIViewController中。主ViewController和CustomOverlay(用於相機控件)。

我的視圖控制器我聲明來源類型和5攝像機控制這樣的覆蓋:

- (void)viewDidLoad 
{ 
    // notification from the CustomOverlay Controller that triggers the eTakePicture method 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(eTakePicture:) name:@"eTakePicture" object:nil]; 

    daysBtn.delegate = self; 
    daysBtn.hidden = YES; 

    picker = [[UIImagePickerController alloc] init]; 
    picker.sourceType = UIImagePickerControllerSourceTypeCamera; 
    picker.cameraDevice = UIImagePickerControllerCameraDeviceFront; 
    picker.showsCameraControls = NO; 
    picker.navigationBarHidden = YES; 
    picker.wantsFullScreenLayout = YES; 
    picker.delegate = self; 

    overlay = [[CustomOverlay alloc] initWithNibName:@"CustomOverlay" bundle:nil]; 
    // Overlay for the camera controls, note the "= overlay.view", the ".view" was important 
    // because the overlay is a new UIViewcontroller (with xib) so you have to call the 
    // view. Most tutorials that I saw were based on UIView so only "= overlay" worked. 
    picker.cameraOverlayView = overlay.view; 
    [self presentModalViewController:picker animated:NO]; 

    [super viewDidLoad]; 
} 

現在,在CustomOverlay,這是一個UIViewController我有拍攝照片按鈕,並希望此按鈕,觸發在主視圖控制器的方法:

- (IBAction)shoot:(id)control { 

    [[NSNotificationCenter defaultCenter] postNotificationName:@"eTakePicture" object:self]; 

} 

並返回到主視圖控制器:

-(void)eTakePicture:(NSNotification *)notification 
{ 
    [picker takePicture]; 
} 

所有上面的代碼將改變多一點,一旦我審查,特別是第一塊,我必須有一個條件,以檢查是否cameraSourceType是可用。

希望幫助別人那裏。任何問題,只要問。