AlarmLevelViewController.m 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // AlarmLevelViewController.m
  3. // FunSDKDemo
  4. //
  5. // Created by Levi on 2018/5/23.
  6. // Copyright © 2018年 Levi. All rights reserved.
  7. //
  8. #import "AlarmLevelViewController.h"
  9. #import "Header.h"
  10. @interface AlarmLevelViewController ()<UITableViewDelegate,UITableViewDataSource>
  11. @property (nonatomic, strong) NSArray *levelArray;
  12. @property (nonatomic, strong) UITableView *levelTableView;
  13. @end
  14. @implementation AlarmLevelViewController
  15. -(UITableView *)levelTableView{
  16. if (!_levelTableView) {
  17. _levelTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 44*3+64) style:UITableViewStylePlain];
  18. _levelTableView.delegate = self;
  19. _levelTableView.dataSource = self;
  20. [_levelTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
  21. }
  22. return _levelTableView;
  23. }
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. //配置导航栏
  27. [self setNaviStyle];
  28. //配置子视图
  29. [self configSubView];
  30. }
  31. -(void)setNaviStyle{
  32. self.navigationItem.title = TS("Alarm_Sensitivity");
  33. }
  34. -(void)configSubView{
  35. self.levelArray = @[TS("Alarm_Lower"),TS("Alarm_Middle"),TS("Alarm_Anvanced")];
  36. [self.view addSubview:self.levelTableView];
  37. }
  38. #pragma mark -- UITableViewDelegate/DataSource
  39. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  40. return 3;
  41. }
  42. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  43. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  44. cell.textLabel.text = self.levelArray[indexPath.row];
  45. return cell;
  46. }
  47. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  48. if (self.alarmLevelBlock) {
  49. self.alarmLevelBlock(self.levelArray[indexPath.row]);
  50. }
  51. [self.navigationController popViewControllerAnimated:NO];
  52. }
  53. @end