GKDBListView.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // GKDBListView.m
  3. // GKPageScrollViewObjc
  4. //
  5. // Created by gaokun on 2020/12/17.
  6. // Copyright © 2020 gaokun. All rights reserved.
  7. //
  8. #import "GKDBListView.h"
  9. @interface GKDBListView()<UITableViewDataSource, UITableViewDelegate>
  10. @property (nonatomic, strong) UITableView *tableView;
  11. @end
  12. @implementation GKDBListView
  13. - (instancetype)init {
  14. if (self = [super init]) {
  15. [self addSubview:self.tableView];
  16. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  17. make.edges.equalTo(self);
  18. }];
  19. }
  20. return self;
  21. }
  22. #pragma mark - UITableViewDataSource & UITableViewDelegate
  23. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  24. return 40;
  25. }
  26. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  27. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
  28. cell.textLabel.text = [NSString stringWithFormat:@"第%zd行", indexPath.row + 1];
  29. return cell;
  30. }
  31. #pragma mark - GKPageSmoothListViewDelegate
  32. - (UIScrollView *)listScrollView {
  33. return self.tableView;
  34. }
  35. - (UIView *)listView {
  36. return self;
  37. }
  38. #pragma mark - 懒加载
  39. - (UITableView *)tableView {
  40. if (!_tableView) {
  41. _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  42. _tableView.dataSource = self;
  43. _tableView.delegate = self;
  44. [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
  45. }
  46. return _tableView;
  47. }
  48. @end