RAHomeViewController+HomeTableDelegate.m 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // RAHomeViewController+HomeTableDelegate.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/6/1.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RAHomeViewController+HomeTableDelegate.h"
  9. #import "RAHomeOrderModel.h"
  10. @implementation RAHomeViewController (HomeTableDelegate)
  11. #pragma mark - TableView Delegate
  12. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  13. return 120.0f;
  14. }
  15. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  16. UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(tableView.bounds), 44.0f)];
  17. header.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:0.8];
  18. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 11, CGRectGetWidth(tableView.bounds) - 100, 22)];
  19. [header addSubview:label];
  20. label.text = [self titleForSection:section];
  21. UIButton *expandBtn = [UIButton buttonWithType:UIButtonTypeSystem];
  22. expandBtn.frame = CGRectMake(CGRectGetWidth(tableView.bounds) - 90, 11, 80, 22);
  23. [expandBtn setTitle:@"More" forState:UIControlStateNormal];
  24. // [expandBtn setTitleColor:expandBtn.tintColor forState:UIControlStateNormal];
  25. // [expandBtn setTitleColor:UIColorFromRGB(0xffffff) forState:UIControlStateHighlighted];
  26. expandBtn.tag = section;
  27. [expandBtn addTarget:self action:@selector(sectionExpandSwithBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  28. [header addSubview:expandBtn];
  29. expandBtn.hidden = ![self hasMoreOrderForSection:section];
  30. return header;
  31. }
  32. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  33. return 44.f;
  34. }
  35. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  36. RAHomeOrderModel *order = [self orderModelForIndexPath:indexPath];
  37. self.currentOrderID = order.orderID;
  38. [self pushDetailViewControllerForModel:order];
  39. }
  40. #pragma mark - Action
  41. - (void)sectionExpandSwithBtnClick:(UIButton *)sender {
  42. [self showMoreOrderForSection:sender.tag];
  43. }
  44. @end