SPSBChooseCityResultTableViewController.m 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // SPSBChooseCityResultTableViewController.m
  3. // 我的社保
  4. //
  5. // Created by shanp on 2021/5/20.
  6. //
  7. #import "SPSBChooseCityResultTableViewController.h"
  8. #import "SPSBUIGeneralHeader.h"
  9. @interface SPSBChooseCityResultTableViewController ()
  10. @end
  11. @implementation SPSBChooseCityResultTableViewController
  12. - (instancetype)init {
  13. self = [super initWithStyle:UITableViewStylePlain backgroundColor:SPSBTableViewBackgroundColorWhite];
  14. if (!self) return nil;
  15. return self;
  16. }
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. [self setupTableView];
  20. }
  21. #pragma mark - Action
  22. #pragma mark - Network Action
  23. #pragma mark - Delegate & DataSource
  24. static NSString * const reuseIdentifier = @"Cell";
  25. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  26. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
  27. if (!cell) {
  28. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
  29. UILabel *label = [UILabel convenienceWithFont:spsb_font(16) text:nil textColor:spsb_333333_color()];
  30. label.tag = 3000;
  31. [cell.contentView addSubview:label];
  32. [label makeConstraints:^(JXHConstraintMaker *make) {
  33. make.leading.equalTo(15);
  34. make.centerY.equalTo(0);
  35. }];
  36. //线
  37. [cell.contentView createLineWithLocation:JXHLineLocationBottom headOffset:15 footOffset:0];
  38. }
  39. if (_spsb_dataArray.count > indexPath.row) {
  40. UILabel *label = (UILabel *)[cell viewWithTag:3000];
  41. if ([_spsb_dataArray[indexPath.row][@"city_name"] isKindOfClass:[NSString class]]) {
  42. label.text = _spsb_dataArray[indexPath.row][@"city_name"];
  43. } else {
  44. label.text = @"";
  45. }
  46. }
  47. return cell;
  48. }
  49. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  50. return _spsb_dataArray.count;
  51. }
  52. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  53. [tableView deselectRowAtIndexPath:indexPath animated:false];
  54. NSString *cityId = _spsb_dataArray[indexPath.row][@"cid"];
  55. _spsb_choose(cityId);
  56. }
  57. - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
  58. jxh_endEdit();
  59. }
  60. #pragma mark - UI
  61. - (void)setupTableView {
  62. self.tableView.rowHeight = 44.f;
  63. }
  64. @end