口袋优选

KBSignInClickView.m 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // KBSignInClickView.m
  3. // YouHuiProject
  4. //
  5. // Created by jcymac on 2018/10/15.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBSignInClickView.h"
  9. #import "KBSignInTableViewCell.h"
  10. @interface KBSignInClickView ()<UITableViewDelegate, UITableViewDataSource, KBSignInTableViewCellDelegate>
  11. @end
  12. @implementation KBSignInClickView
  13. /*
  14. // Only override drawRect: if you perform custom drawing.
  15. // An empty implementation adversely affects performance during animation.
  16. - (void)drawRect:(CGRect)rect {
  17. // Drawing code
  18. }
  19. */
  20. - (instancetype)initWithFrame:(CGRect)frame {
  21. self = [super initWithFrame:frame];
  22. if (self) {
  23. self.backgroundColor = [UIColor clearColor];
  24. self.clickTableArry = [NSMutableArray arrayWithCapacity:0];
  25. [self makeUI];
  26. }
  27. return self;
  28. }
  29. - (void)makeUI {
  30. [self addSubview:self.clickTableView];
  31. [self.clickTableView registerClass:[KBSignInTableViewCell class] forCellReuseIdentifier:@"KBSignInTableViewCell"];
  32. }
  33. - (void)refreshTableViewWithArry:(NSArray *)tableArry {
  34. [self.clickTableArry removeAllObjects];
  35. for (NSDictionary *dic in tableArry) {
  36. KBSignDetailModel *model = [KBSignDetailModel yy_modelWithJSON:dic];
  37. [self.clickTableArry addObject:model];
  38. }
  39. [self.clickTableView reloadData];
  40. }
  41. - (UITableView *)clickTableView {
  42. if (!_clickTableView) {
  43. _clickTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0 , FITSIZE(323), FITSIZE(72*4)) style:UITableViewStylePlain];
  44. _clickTableView.estimatedSectionHeaderHeight = 0;
  45. _clickTableView.estimatedSectionFooterHeight = 0;
  46. _clickTableView.delegate = self;
  47. _clickTableView.dataSource = self;
  48. _clickTableView.showsVerticalScrollIndicator = NO;
  49. _clickTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  50. _clickTableView.backgroundColor = [UIColor clearColor];
  51. _clickTableView.scrollEnabled = NO;
  52. }
  53. return _clickTableView;
  54. }
  55. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  56. return self.clickTableArry.count;
  57. }
  58. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  59. KBSignInTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"KBSignInTableViewCell" forIndexPath:indexPath];
  60. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  61. cell.clickDelegate = self;
  62. [cell refreshCellWithModel:self.clickTableArry[indexPath.row] andIndexPath:indexPath];
  63. return cell;
  64. }
  65. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  66. return FITSIZE(72);
  67. }
  68. - (void)clickCellIndexPath:(NSIndexPath *)index {
  69. [self.clickViewDelegate clickViewIndexPath:index];
  70. }
  71. @end