diskListTableView.m 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //
  2. // diskListTableView.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2024/1/23.
  6. //
  7. #import "diskListTableView.h"
  8. #import "diskListTableCell.h"
  9. #import "cloudPhoneExtraFileListModel.h"
  10. @interface diskListTableView()<UITableViewDataSource,UITableViewDelegate>
  11. @end
  12. @implementation diskListTableView
  13. #pragma mark - init
  14. - (instancetype)init {
  15. self = [super init];
  16. if (self) {
  17. [self initCommon];
  18. }
  19. return self;
  20. }
  21. - (instancetype)initWithCoder:(NSCoder *)coder {
  22. self = [super initWithCoder:coder];
  23. if (self) {
  24. [self initCommon];
  25. }
  26. return self;
  27. }
  28. - (id)initWithFrame:(CGRect)frame {
  29. self = [super initWithFrame:frame];
  30. if (self) {
  31. [self initCommon];
  32. }
  33. return self;
  34. }
  35. - (void)initCommon {
  36. self.delegate = self;
  37. self.dataSource = self;
  38. self.separatorStyle = UITableViewCellSeparatorStyleNone;
  39. //self.backgroundColor = [UIColor colorWithRed:235.0/255.0 green:235.0/255.0 blue:235.0/255.0 alpha:1.0];
  40. self.backgroundColor = [UIColor clearColor];
  41. }
  42. #pragma mark - uitableviewDelegate
  43. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  44. static NSString *cellIdentifer = @"diskListTableCell";
  45. diskListTableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
  46. if(cell == nil){
  47. cell = [[diskListTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifer];
  48. cell.accessoryType = UITableViewCellAccessoryNone;
  49. }
  50. NSInteger row = indexPath.row;
  51. if(row < _diskListArr.count){
  52. cloudPhoneExtraFileModel *model = _diskListArr[row];
  53. cell.curModel = model;
  54. }
  55. KWeakSelf
  56. cell.didClickSwitch = ^(BOOL SwitchOn) {
  57. [weakSelf setModelSelectInRow:row];
  58. };
  59. return cell;
  60. }
  61. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  62. return _diskListArr.count;
  63. }
  64. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  65. return 70.0;
  66. }
  67. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  68. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  69. }
  70. - (void)setDiskListArr:(NSMutableArray *)diskListArr
  71. {
  72. _diskListArr = diskListArr;
  73. [self reloadData];
  74. }
  75. - (void)setModelSelectInRow:(NSInteger)row
  76. {
  77. for (int i=0; i<_diskListArr.count; i++) {
  78. cloudPhoneExtraFileModel *model = _diskListArr[i];
  79. model.isCheckType = NO;
  80. if(i == row){
  81. model.isCheckType = YES;
  82. if(_didClickDiskModel){
  83. _didClickDiskModel(model.extraPath);
  84. }
  85. }
  86. }
  87. [self reloadData];
  88. }
  89. @end