TheoryTrainVC.m 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //
  2. // TheoryTrainVC.m
  3. // jiaPei
  4. //
  5. // Created by EchoShacolee on 2018/6/7.
  6. // Copyright © 2018年 JCZ. All rights reserved.
  7. //
  8. //活体检测
  9. //活体检测
  10. //活体检测
  11. //活体检测
  12. //活体检测
  13. #import "TheoryTrainVC.h"
  14. #import <WebKit/WebKit.h>
  15. #import <AFNetworking.h>
  16. //#import <MGLivenessDetection/MGLivenessDetection.h>//活体检测
  17. @interface TheoryTrainVC ()<WKNavigationDelegate>
  18. @property (weak, nonatomic) IBOutlet WKWebView *webView;
  19. @end
  20. @implementation TheoryTrainVC
  21. - (void)dealloc
  22. {
  23. [self.webView removeObserver:self forKeyPath:@"title"];
  24. }
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. self.webView.navigationDelegate = self;
  28. _file = @"http://124.133.246.162:18080/jpv2H5_2/index.html#/h5/login?account=370021199812212931&pwd=123456";
  29. // [self myInit];
  30. // if (![MGLiveManager getLicense]) {
  31. // [MGLiveManager licenseForNetWokrFinish:^(bool License) {
  32. // NSLog(@"%@", [NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"title_license", nil), License ? NSLocalizedString(@"title_success", nil) : NSLocalizedString(@"title_failure", nil)]);
  33. // }];
  34. // }
  35. // [self startDetect:nil];
  36. }
  37. -(void)myInit
  38. {
  39. [self configNavigationBar];
  40. [self.view setBackgroundColor:[UIColor whiteColor]];
  41. WKWebView *view = [[WKWebView alloc] initWithFrame:kFrame];
  42. view.height = kSize.height - kNavOffSet;
  43. view.navigationDelegate = self;
  44. [self.view addSubview: view];
  45. NSURLRequest *request = nil;
  46. request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:_file]];
  47. NSLog(@"%@",request);
  48. [view loadRequest:request];
  49. //监听导航栏标题
  50. [self.webView addObserver:self forKeyPath:@"title"options:NSKeyValueObservingOptionNew context:NULL];
  51. }
  52. - (void)didReceiveMemoryWarning {
  53. [super didReceiveMemoryWarning];
  54. // Dispose of any resources that can be recreated.
  55. }
  56. #pragma mark -
  57. // 页面加载失败时调用
  58. - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error{
  59. [MBProgressHUD hideHUDForView:self.view];
  60. }
  61. // 页面加载完毕时调用
  62. - (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{
  63. [MBProgressHUD hideHUDForView:self.view];
  64. }
  65. ////@lee 这个写到一半
  66. //-(void)observeValueForKeyPath:(nullableNSString*)keyPathofObject:(nullableid)objectchange:(nullableNSDictionary*)changecontext:(nullablevoid*)context
  67. //{
  68. // if([keyPath isEqualToString:@"title"]){
  69. // self.navigationItem.title=self.webView.title;
  70. // }
  71. //}
  72. #pragma mark - StartDetect
  73. //- (void)startDetect:(UIButton *)sender {//@lee-mark
  74. // if (![MGLiveManager getLicense]) {
  75. // UIAlertController* alertC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"title_remind", nil)
  76. // message:NSLocalizedString(@"key_sdk_license_failure", nil)
  77. // preferredStyle:UIAlertControllerStyleAlert];
  78. // UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"title_sure", nil)
  79. // style:UIAlertActionStyleCancel
  80. // handler:nil];
  81. // [alertC addAction:cancelAction];
  82. // [self presentViewController:alertC
  83. // animated:YES
  84. // completion:nil];
  85. // return;
  86. // }
  87. //
  88. // sender.userInteractionEnabled = NO;
  89. // // [self.resultImageV setImage:nil];
  90. // // [self.messageLabel setText:nil];
  91. //
  92. // MGLiveManager *liveManager = [[MGLiveManager alloc] init];
  93. // liveManager.actionCount = 3;//self.countSeg.selectedSegmentIndex + 1;
  94. // liveManager.actionTimeOut = 10;//(int)self.timeoutStepper.value;
  95. // liveManager.randomAction = YES;//self.randomSwitch.isOn;
  96. // // if (!self.randomSwitch.isOn) {
  97. // // NSMutableArray* actionMutableArray = [[NSMutableArray alloc] initWithCapacity:liveManager.actionCount];
  98. // // for (int i = 1; i <= liveManager.actionCount; i++) {
  99. // // [actionMutableArray addObject:[NSNumber numberWithInt:i]];
  100. // // }
  101. // // liveManager.actionArray = (NSArray *)actionMutableArray;
  102. // // }
  103. // [liveManager startFaceDecetionViewController:self
  104. // finish:^(FaceIDData *finishDic, UIViewController *viewController) {
  105. // sender.userInteractionEnabled = YES;
  106. // [viewController dismissViewControllerAnimated:YES completion:nil];
  107. // NSData *resultData = [[finishDic images] valueForKey:@"image_best"];
  108. // UIImage *resultImage = [UIImage imageWithData:resultData];
  109. // // [self.resultImageV setImage:resultImage];
  110. // // [self.messageLabel setText:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"key_action_live_detect", nil), NSLocalizedString(@"title_success", nil)]];
  111. // // [self.messageLabel setTextColor:[UIColor blueColor]];
  112. // }
  113. // error:^(MGLivenessDetectionFailedType errorType, UIViewController *viewController) {
  114. // sender.userInteractionEnabled = YES;
  115. // [viewController dismissViewControllerAnimated:YES completion:nil];
  116. // // [self showErrorString:errorType];
  117. // // [self.messageLabel setTextColor:[UIColor redColor]];
  118. // }];
  119. //
  120. //
  121. //}
  122. //
  123. //
  124. //
  125. ///*
  126. //#pragma mark - Navigation
  127. //
  128. // In a storyboard-based application, you will often want to do a little preparation before navigation
  129. //- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  130. // Get the new view controller using [segue destinationViewController].
  131. // Pass the selected object to the new view controller.
  132. //}
  133. //*/
  134. @end