TRListVC.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //
  2. // TRListVC.m
  3. // jiaPei
  4. //
  5. // Created by apple on 15/12/24.
  6. // Copyright © 2015年 JCZ. All rights reserved.
  7. //
  8. #import "TRListVC.h"
  9. #import "CLCell.h"
  10. #import "TRDetailVC.h"
  11. #import "TrafficRulesViewController.h"
  12. @interface TRListVC ()<UITableViewDataSource,UITableViewDelegate>
  13. {
  14. UITableView* myTableView;
  15. }
  16. @end
  17. @implementation TRListVC
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. [self myInit];
  21. }
  22. - (void)didReceiveMemoryWarning {
  23. [super didReceiveMemoryWarning];
  24. // Dispose of any resources that can be recreated.
  25. }
  26. -(void)myInit
  27. {
  28. [self.view setBackgroundColor:[UIColor whiteColor]];
  29. [self configNavigationBar];
  30. UIBarButtonItem* bbi = [[UIBarButtonItem alloc] initWithTitle:@"关闭" style:UIBarButtonItemStylePlain target:self action:@selector(goBack)];
  31. bbi.tintColor = kTitleColor;
  32. self.navigationItem.rightBarButtonItem = bbi;
  33. UITableView *tv = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-kNavOffSet)];
  34. [tv setDelegate:self];
  35. [tv setDataSource:self];
  36. [self.view addSubview:tv];
  37. //这一句代码的目的是当表中行数较少时 滑动时 没有行的地方不出现分割线
  38. tv.tableFooterView = [UIView new];
  39. myTableView = tv;
  40. }
  41. -(void)goBack
  42. {
  43. [self.navigationController popViewControllerAnimated:YES];
  44. }
  45. #pragma mark -
  46. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  47. {
  48. return _models.count;
  49. }
  50. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  51. {
  52. //已封装有重用机制
  53. CLCell *cell= [CLCell cellForTableView:tableView Style:UITableViewCellStyleDefault];
  54. [cell.textLabel setText:_models[indexPath.row]];
  55. [cell.imageView setImage:defaultImg];
  56. return cell;
  57. }
  58. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  59. {
  60. //什么作用
  61. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  62. TRDetailVC *vc=[[TRDetailVC alloc]init];
  63. [vc setFile:_models[indexPath.row]];
  64. [self navPushHideTabbarToVC:vc];
  65. }
  66. @end