123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- //
- // 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 ()<UITableViewDataSource,UITableViewDelegate>
- {
- 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
|