ParamViewController.mm 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //
  2. // ParamViewController.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2018/11/9.
  6. // Copyright © 2018年 XM. All rights reserved.
  7. //
  8. #import "ParamViewController.h"
  9. #import "ItemViewController.h"
  10. #import "ItemTableviewCell.h"
  11. #import "VideoRotainConfig.h"
  12. @interface ParamViewController () <UITableViewDelegate,UITableViewDataSource,VideoRotainConfigDelegate>
  13. {
  14. VideoRotainConfig *config; //摄像机参数配置 (图像翻转等等)
  15. UITableView *paramTableView;
  16. NSMutableArray *paramTitleArray;
  17. }
  18. @end
  19. @implementation ParamViewController
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. //初始化tableview数据
  23. [self initDataSource];
  24. [self configSubView];
  25. // 获取摄像机参数配置
  26. [self getVideoRotainConfig];
  27. }
  28. - (void)viewWillDisappear:(BOOL)animated{
  29. //有加载状态、则取消加载
  30. if ([SVProgressHUD isVisible]){
  31. [SVProgressHUD dismiss];
  32. }
  33. }
  34. #pragma mark - 获取摄像机参数配置
  35. - (void)getVideoRotainConfig {
  36. [SVProgressHUD showWithStatus:TS("")];
  37. if (config == nil) {
  38. config = [[VideoRotainConfig alloc] init];
  39. config.delegate = self;
  40. }
  41. //调用获取摄像机图像翻转等参数的接口
  42. [config getRotainConfig];
  43. }
  44. #pragma mark 获取摄像机参数代理回调
  45. - (void)getVideoRotainConfigResult:(NSInteger)result {
  46. if (result >0) {
  47. //成功,刷新界面数据
  48. [self.paramTableView reloadData];
  49. [SVProgressHUD dismiss];
  50. }else{
  51. [MessageUI ShowErrorInt:(int)result];
  52. }
  53. }
  54. #pragma mark - 保存摄像机参数配置 (图像翻转)
  55. -(void)saveConfig{
  56. [SVProgressHUD show];
  57. [config setRotainConfig];
  58. }
  59. #pragma mark 保存摄像机参数代理回调
  60. - (void)setVideoRotainConfigResult:(NSInteger)result {
  61. if (result >0) {
  62. //成功
  63. [SVProgressHUD dismissWithSuccess:TS("Success")];
  64. }else{
  65. [MessageUI ShowErrorInt:(int)result];
  66. }
  67. }
  68. #pragma mark - tableView代理方法
  69. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  70. return paramTitleArray.count;
  71. }
  72. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  73. ItemTableviewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ItemTableviewCell"];
  74. if (!cell) {
  75. cell = [[ItemTableviewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ItemTableviewCell"];
  76. }
  77. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  78. NSString *title = [paramTitleArray objectAtIndex:indexPath.row];
  79. cell.textLabel.text = title;
  80. if ([config checkParam] == NO) {
  81. //当前配置参数无效,不能刷新
  82. return cell;
  83. }
  84. if ([title isEqualToString:TS("Flip_Vertical")]) {
  85. cell.Labeltext.text = [config getPictureFlip];
  86. }else if ([title isEqualToString:TS("Flip_Horizontal")]) {
  87. cell.Labeltext.text =[config getPictureMirror];
  88. }
  89. return cell;
  90. }
  91. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  92. if ([config checkParam] == NO) {
  93. return; //图像翻转数据异常,无法进行配置
  94. }
  95. NSString *titleStr = paramTitleArray[indexPath.row];
  96. //初始化各个配置的item单元格
  97. ItemViewController *itemVC = [[ItemViewController alloc] init];
  98. [itemVC setTitle:titleStr];
  99. __weak typeof(self) weakSelf = self;
  100. itemVC.itemSelectStringBlock = ^(NSString *encodeString) {
  101. //itemVC的单元格点击回调,设置各种属性
  102. ItemTableviewCell *cell = [weakSelf.paramTableView cellForRowAtIndexPath:indexPath];
  103. cell.Labeltext.text = encodeString;
  104. if ([cell.textLabel.text isEqualToString:TS("Flip_Vertical")]) {
  105. [config setPictureFlip:encodeString];
  106. }else if ([cell.textLabel.text isEqualToString:TS("Flip_Horizontal")]){
  107. [config setPictureMirror:encodeString];
  108. }else{
  109. return;
  110. }
  111. };
  112. //点击单元格之后进行分别赋值
  113. if ([titleStr isEqualToString:TS("Flip_Vertical")]) {
  114. NSMutableArray *array = [[config getEnableArray] mutableCopy];
  115. [itemVC setValueArray:array];
  116. }else if ([titleStr isEqualToString:TS("Flip_Horizontal")]){
  117. NSMutableArray *array = [[config getEnableArray] mutableCopy];
  118. [itemVC setValueArray:array];
  119. }else{
  120. return;
  121. }
  122. //如果赋值成功,跳转到下一级界面
  123. [self.navigationController pushViewController:itemVC animated:YES];
  124. }
  125. #pragma mark - 界面和数据初始化
  126. - (void)configSubView {
  127. UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(saveConfig)];
  128. self.navigationItem.rightBarButtonItem = rightButton;
  129. [self.view addSubview:self.paramTableView];
  130. }
  131. - (UITableView *)paramTableView {
  132. if (!paramTableView) {
  133. paramTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight ) style:UITableViewStylePlain];
  134. paramTableView.delegate = self;
  135. paramTableView.dataSource = self;
  136. [paramTableView registerClass:[ItemTableviewCell class] forCellReuseIdentifier:@"ItemTableviewCell"];
  137. }
  138. return paramTableView;
  139. }
  140. #pragma mark - 界面和数据初始化
  141. - (void)initDataSource {
  142. paramTitleArray = (NSMutableArray*)@[TS("Flip_Vertical"),TS("Flip_Horizontal")];
  143. }
  144. - (void)didReceiveMemoryWarning {
  145. [super didReceiveMemoryWarning];
  146. // Dispose of any resources that can be recreated.
  147. }
  148. @end