(コメントと編集で解決された質問)質問は解決されませんが、コメントで解決された問題(またはチャットで延長))
OPは書いた:
解決策になったのは次のとおりです。
2つのUIViewControllerがあります。メインのViewControllerとCustomOverlay(カメラコントロール用)。
ViewController私は、このようなカメラコントロールのソースタイプとオーバーレイを宣言します:
- (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];
}
UIViewControllerであるCustomOverlayについて、私は画像を撮るボタンを持っていて、このボタンを使ってメインViewControllerのメソッドをトリガーします:
- (IBAction)shoot:(id)control {
[[NSNotificationCenter defaultCenter] postNotificationName:@"eTakePicture" object:self];
}
メインのViewController:
-(void)eTakePicture:(NSNotification *)notification
{
[picker takePicture];
}
上記のコードはすべて、私がcameraSourceTypeが利用可能かどうかを確認するための条件が必要な最初のブロックを見直すと少し変わります。
誰かに助けてくれることを願っています。質問があれば、尋ねてください。