我有一个小的 iOS 项目/测试,我正在调用一个 UIImagePickerContoller 并将源设置为 iPhone 相机。
我想将这个“实时”相机加载到我界面中一个较小的 UIView 框中。我让相机加载并显示,但不在 UIView 中。这是我正在使用的代码:
- (void)viewDidAppear:(BOOL)animated {
UIImagePickerController *scope = [[UIImagePickerController alloc] init];
[scope setSourceType:UIImagePickerControllerSourceTypeCamera];
[scope setShowsCameraControls:NO];
[scope setEditing:NO];
[scope setNavigationBarHidden:YES];
[cameraDisplayView addSubview:scope.view];
[scope viewWillAppear:YES];
[super viewDidAppear:YES];
}
最佳答案
您需要使用 cameraOverlayView
属性在相机 View 之上绘制其他 View ,而不是相反。
请参阅 UIImagePickerController 的文档.您不能强制相机选择器 Controller 进入 UIView
,您必须在相机选择器 Controller 之上绘制。
(然后您可以将其中一个叠加 View 设置为 clearColor
以获得相机 Controller 的窗口。)
关于iphone - UIView 中的 UIImagePickerController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6485963/