DeviceAddViewController.m 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // DeviceAddViewController.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2018/11/29.
  6. // Copyright © 2018年 XM. All rights reserved.
  7. //
  8. #import "DeviceAddViewController.h"
  9. #import "SerialNumAddViewController.h"
  10. #import "IPAddViewController.h"
  11. #import "LANSearchViewController.h"
  12. #import "QuickConfigurationViewController.h"
  13. #import "Header.h"
  14. @interface DeviceAddViewController () <UITableViewDelegate,UITableViewDataSource>
  15. {
  16. NSMutableArray *titleArray;
  17. UITableView *mainTableView;
  18. }
  19. @end
  20. @implementation DeviceAddViewController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. //设置导航栏样式
  24. [self setNaviStyle];
  25. [self initData];
  26. //配置子试图
  27. [self configSubView];
  28. }
  29. - (void)setNaviStyle {
  30. self.navigationItem.title = TS("About_Device");
  31. }
  32. - (void)initData {
  33. titleArray = (NSMutableArray*)@[TS("Connect_DevMac"),TS("add_by_ip/domain"),TS("Connect_localNetwork"),TS("Connect_WiFi")];
  34. }
  35. - (void)configSubView {
  36. [self.view addSubview:self.mainTableView];
  37. }
  38. #pragma mark -- UITableViewDelegate/dataSource
  39. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  40. return 50;
  41. }
  42. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  43. return titleArray.count;
  44. }
  45. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  46. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mainCell"];
  47. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  48. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  49. cell.textLabel.text = [titleArray objectAtIndex:indexPath.row];
  50. return cell;
  51. }
  52. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  53. NSString *title = [titleArray objectAtIndex:indexPath.row];
  54. if ([title isEqualToString:TS("Connect_DevMac")]) {
  55. //序列号添加设备
  56. SerialNumAddViewController *addVC = [[SerialNumAddViewController alloc] init];
  57. [self.navigationController pushViewController:addVC animated:YES];
  58. }
  59. if ([title isEqualToString:TS("add_by_ip/domain")]) {
  60. //ip/域名添加设备
  61. IPAddViewController *addVC = [[IPAddViewController alloc] init];
  62. [self.navigationController pushViewController:addVC animated:YES];
  63. }
  64. if ([title isEqualToString:TS("Connect_localNetwork")]) {
  65. //局域网添加设备
  66. LANSearchViewController *searchVC = [[LANSearchViewController alloc] init];
  67. [self.navigationController pushViewController:searchVC animated:YES];
  68. }
  69. if ([title isEqualToString:TS("Connect_WiFi")]) {
  70. //快速配置
  71. QuickConfigurationViewController *configVC = [[QuickConfigurationViewController alloc] init];
  72. [self.navigationController pushViewController:configVC animated:YES];
  73. }
  74. }
  75. - (UITableView *)mainTableView {
  76. if (!mainTableView) {
  77. mainTableView = [[UITableView alloc] initWithFrame:CGRectMake(10, 0, ScreenWidth - 20, ScreenHeight) style:UITableViewStylePlain];
  78. mainTableView.delegate = self;
  79. mainTableView.dataSource = self;
  80. [mainTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"mainCell"];
  81. }
  82. return mainTableView;
  83. }
  84. - (void)didReceiveMemoryWarning {
  85. [super didReceiveMemoryWarning];
  86. // Dispose of any resources that can be recreated.
  87. }
  88. /*
  89. #pragma mark - Navigation
  90. // In a storyboard-based application, you will often want to do a little preparation before navigation
  91. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  92. // Get the new view controller using [segue destinationViewController].
  93. // Pass the selected object to the new view controller.
  94. }
  95. */
  96. @end