MOShareFriendListTableView.m 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // MOShareFriendListTableView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2023/11/20.
  6. //
  7. #import "MOShareFriendListTableView.h"
  8. @interface MOShareFriendListTableView () <UITableViewDelegate,UITableViewDataSource>
  9. @end
  10. @implementation MOShareFriendListTableView
  11. - (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
  12. {
  13. self = [super initWithFrame:frame style:style];
  14. if (self)
  15. {
  16. self.delegate = self;
  17. self.dataSource = self;
  18. [self registerClass:[MOSelectMemberListCell class] forCellReuseIdentifier:MOSelectMemberListCell_ID];
  19. }
  20. return self;
  21. }
  22. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  23. {
  24. return 1;
  25. }
  26. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  27. {
  28. return self.dataArr.count;
  29. }
  30. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  31. MOPersonList *model = self.dataArr[indexPath.row];
  32. MOSelectMemberListCell *cell = [tableView dequeueReusableCellWithIdentifier:MOSelectMemberListCell_ID];
  33. if (cell == nil){
  34. cell = [[MOSelectMemberListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MOSelectMemberListCell_ID];
  35. }
  36. cell.model = model;
  37. return cell;
  38. }
  39. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  40. {
  41. return 76.0;
  42. }
  43. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  44. {
  45. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  46. MOPersonList *model = self.dataArr[indexPath.row];
  47. model.isChoose = !model.isChoose;
  48. [self reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
  49. self.cellClickBlock ? self.cellClickBlock(model) : nil;
  50. }
  51. - (NSMutableArray *)dataArr{
  52. if(!_dataArr){
  53. _dataArr = [NSMutableArray array];
  54. }
  55. return _dataArr;
  56. }
  57. @end