EncodeItemViewController.m 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // EncodeItemViewController.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2018/11/6.
  6. // Copyright © 2018年 XM. All rights reserved.
  7. //
  8. #import "EncodeItemViewController.h"
  9. #import "Header.h"
  10. @interface EncodeItemViewController () <UITableViewDataSource,UITableViewDelegate>
  11. @property (nonatomic, strong) NSArray *itemArray;
  12. @property (nonatomic, strong) UITableView *tableView;
  13. @end
  14. @implementation EncodeItemViewController
  15. - (void)setValueArray:(NSMutableArray *)array {
  16. self.itemArray = [array mutableCopy];
  17. [self.tableView reloadData];
  18. }
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. //配置子视图
  22. [self configSubView];
  23. }
  24. -(void)configSubView{
  25. [self.view addSubview:self.tableView];
  26. }
  27. #pragma mark - tableview代理方法
  28. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  29. return self.itemArray.count;
  30. }
  31. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  32. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellIdentifier"];
  33. cell.textLabel.text = self.itemArray[indexPath.row];
  34. return cell;
  35. }
  36. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  37. if (self.itemSelectStringBlock) {
  38. self.itemSelectStringBlock(self.itemArray[indexPath.row]);
  39. }
  40. [self.navigationController popViewControllerAnimated:YES];
  41. }
  42. -(UITableView *)tableView{
  43. if (!_tableView) {
  44. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) style:UITableViewStylePlain];
  45. _tableView.delegate = self;
  46. _tableView.dataSource = self;
  47. [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cellIdentifier"];
  48. }
  49. return _tableView;
  50. }
  51. @end