我如何覆盖IOS中的本地摄像机视图的文本框

执行构build时遇到困难,我正在尝试完成。

我有版本1和版本2完成。

构build1 – 一个简单的空白屏幕与两个文本框与alignment限制

构build2 – 当应用程序运行时,它调用IOS设备的本地后视摄像头。

我的第三个版本是这两个以前的版本一起作为一个,其中本地摄像头显示实时video馈送,并且覆盖是两个文本框与他们的alignment限制。

我不确定如何将两位代码放在一起。

我目前的代码有:

构build1 – .h文件

#import <UIKit/UIKit.h> @interface ViewController : UIViewController @property (strong, nonatomic) IBOutlet UIView *TestTextBox; @property (weak, nonatomic) IBOutlet UITextView *TestTetBox2; @end 

构build1 – .m文件

 #import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize TestTextBox; @synthesize TestTetBox2; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end 

构build2 – .h文件

 #import <UIKit/UIKit.h> @interface ViewController : UIViewController <UIImagePickerControllerDelegate,UINavigationControllerDelegate> @property (strong, nonatomic) IBOutlet UIImageView *imageView; @end 

构build2 – .m文件

 #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } -(void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; if (self.imageView.image == nil) { UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init]; imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; imagePickerController.delegate = self; imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; //Defualts to Native Camera View imagePickerController.showsCameraControls = NO; //removes camera controlls [self presentViewController:imagePickerController animated:NO completion:nil]; } else{ } } -(void) imagePickerControllerDidCancel:(UIImagePickerController *)picker{ [self dismissViewControllerAnimated:YES completion:nil]; } -(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{ UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage]; self.imageView.image = image; [self dismissViewControllerAnimated:YES completion:nil]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end 

您无法使用UIImagePickerController在自定义UIView呈现相机。 您需要使用AVFoundation框架在自定义UIView呈现相机。