Возникли проблемы с выполнением сборки, которую я пытаюсь завершить.
У меня есть сборка 1 и сборка 2 завершены.
Сборка 1 — простой пустой экран с двумя текстовыми полями с ограничениями выравнивания.
Сборка 2. Когда приложение запускается, оно вызывает родную заднюю камеру устройства IOS.
Моя третья сборка — это две предыдущие сборки, объединенные в одну, где родная камера показывает трансляцию видео в реальном времени, а наложенные друг на друга — два текстовых поля с их ограничениями выравнивания.
Я не уверен, как объединить два бита кода.
Код, который у меня сейчас есть:
Сборка 1 — файл .h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIView *TestTextBox;
@property (weak, nonatomic) IBOutlet UITextView *TestTetBox2;
@end
Сборка 1 - файл .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
Сборка 2 - файл .h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UIImagePickerControllerDelegate,UINavigationControllerDelegate>
@property (strong, nonatomic) IBOutlet UIImageView *imageView;
@end
Сборка 2 - файл .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