RQWrongAndCollectionVC.m 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // RQWrongAndCollectionVC.m
  3. // SDJK
  4. //
  5. // Created by 张嵘 on 2022/5/23.
  6. //
  7. #import "RQWrongAndCollectionVC.h"
  8. @interface RQWrongAndCollectionVC ()
  9. /// viewModel
  10. @property (nonatomic, readwrite, strong) RQWrongAndCollectionViewModel *viewModel;
  11. @property (nonatomic, readwrite, strong) UIImageView *headerImageView;
  12. @property (nonatomic, readwrite, strong) UIImageView *footerImageView;
  13. @end
  14. @implementation RQWrongAndCollectionVC
  15. @dynamic viewModel;
  16. #pragma mark - SystemMethod
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. /// 初始化
  20. [self rq_setup];
  21. }
  22. - (void)viewDidLayoutSubviews {
  23. [super viewDidLayoutSubviews];
  24. }
  25. #pragma mark - PrivateMethods
  26. - (void)rq_setup {
  27. self.tableView.tableHeaderView = self.headerImageView;
  28. self.tableView.tableFooterView = self.footerImageView;
  29. }
  30. #pragma mark - OverrideMethods
  31. - (UIEdgeInsets)contentInset {
  32. return UIEdgeInsetsMake(RQ_APPLICATION_TOP_BAR_HEIGHT, 0, RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT, 0);
  33. }
  34. - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  35. RQWrongAndCollectionCell *wrongAndCollectionCell = [RQWrongAndCollectionCell cellWithTableView:tableView];
  36. RQSynExerciseCell *synExerciseCell = [RQSynExerciseCell cellWithTableView:tableView];
  37. return (indexPath.row == 2)? synExerciseCell : wrongAndCollectionCell;
  38. }
  39. - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  40. if (indexPath.row == 2) {
  41. RQSynExerciseCell *synExerciseCell = (RQSynExerciseCell *)cell;
  42. [synExerciseCell bindViewModel:object];
  43. } else {
  44. RQWrongAndCollectionCell *wrongAndCollectionCell = (RQWrongAndCollectionCell *)cell;
  45. [wrongAndCollectionCell bindViewModel:object];
  46. }
  47. }
  48. #pragma mark - LazyLoad
  49. - (UIImageView *)headerImageView {
  50. if (!_headerImageView) {
  51. _headerImageView = [[UIImageView alloc] initWithImage:RQImageNamed(@"头部图")];
  52. _headerImageView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH, RQ_FIT_HORIZONTAL(148.f));
  53. }
  54. return _headerImageView;
  55. }
  56. - (UIImageView *)footerImageView {
  57. if (!_footerImageView) {
  58. _footerImageView = [[UIImageView alloc] initWithImage:RQImageNamed(@"错题收藏底部图")];
  59. _footerImageView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH, RQ_FIT_HORIZONTAL(222.f));
  60. }
  61. return _footerImageView;
  62. }
  63. @end