我正在开发一个应用程序,我需要在其中保持打开全屏摄像头并在其上添加一个按钮(右下角)。我用谷歌搜索但找不到任何健康的解决方案。提前致谢。祝你有美好的一天。 已编辑
- (void) showCameraUI {
[self startCameraControllerFromViewController: self
usingDelegate: self];
}
- (BOOL) startCameraControllerFromViewController: (UIViewController*) controller
usingDelegate: (id <UIImagePickerControllerDelegate,
UINavigationControllerDelegate>) delegate {
if (([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera] == NO)
|| (delegate == nil)
|| (controller == nil))
return NO;
NSLog(@"Start Camera Controller method...");
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
// Displays a control that allows the user to choose picture or
// movie capture, if both are available:
cameraUI.mediaTypes =
[UIImagePickerController availableMediaTypesForSourceType:
UIImagePickerControllerSourceTypeCamera];
// Hides the controls for moving & scaling pictures, or for
// trimming movies. To instead show the controls, use YES.
cameraUI.allowsEditing = NO;
cameraUI.delegate = delegate;
[controller presentModalViewController: cameraUI animated: YES];
return YES;
}
PS:我还在UINavigationControllerDelegate,UIImagePickerControllerDelegate
头文件中添加了协议,但它仍然没有打开相机并显示项目的默认视图。