// // TRListVC.m // jiaPei // // Created by apple on 15/12/24. // Copyright © 2015年 JCZ. All rights reserved. // #import "TRListVC.h" #import "CLCell.h" #import "TRDetailVC.h" #import "TrafficRulesViewController.h" @interface TRListVC () { UITableView* myTableView; } @end @implementation TRListVC - (void)viewDidLoad { [super viewDidLoad]; [self myInit]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)myInit { [self.view setBackgroundColor:[UIColor whiteColor]]; [self configNavigationBar]; UIBarButtonItem* bbi = [[UIBarButtonItem alloc] initWithTitle:@"关闭" style:UIBarButtonItemStylePlain target:self action:@selector(goBack)]; bbi.tintColor = kTitleColor; self.navigationItem.rightBarButtonItem = bbi; UITableView *tv = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-kNavOffSet)]; [tv setDelegate:self]; [tv setDataSource:self]; [self.view addSubview:tv]; //这一句代码的目的是当表中行数较少时 滑动时 没有行的地方不出现分割线 tv.tableFooterView = [UIView new]; myTableView = tv; } -(void)goBack { [self.navigationController popViewControllerAnimated:YES]; } #pragma mark - - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return _models.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //已封装有重用机制 CLCell *cell= [CLCell cellForTableView:tableView Style:UITableViewCellStyleDefault]; [cell.textLabel setText:_models[indexPath.row]]; [cell.imageView setImage:defaultImg]; return cell; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //什么作用 [tableView deselectRowAtIndexPath:indexPath animated:YES]; TRDetailVC *vc=[[TRDetailVC alloc]init]; [vc setFile:_models[indexPath.row]]; [self navPushHideTabbarToVC:vc]; } @end