- (void )viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBar.barTintColor = TitleCOLOR;
self.navigationController.navigationBar.translucent = NO;
[self.navigationController.navigationBar setTitleTextAttributes:
@{NSFontAttributeName:[UIFont systemFontOfSize:16],
NSForegroundColorAttributeName:[UIColor whiteColor]}];
self.view.backgroundColor = [UIColor whiteColor];
//自定义返回按钮
UIBarButtonItem*backItem=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStyleDone target:self action:@selector(backBtn:)];
self.navigationItem.leftBarButtonItem=backItem;
// Do any additional setup after loading the view.
self.myTableView.delegate= self;
self.myTableView.dataSource = self;
self.myTableView.tableFooterView =[[UIView alloc] initWithFrame:CGRectZero];//删除多余的cell分割线
self.myTableView.backgroundColor = BGCOLOR;
[self.myTableView registerNib:[UINib nibWithNibName:@"" bundle:nil] forCellReuseIdentifier:@""];
// self.myTableView.separatorStyle= UITableViewCellSeparatorStyleNone;//去除分割线
//这个去除分割线方法必须写在注册cell的后面。
}
-(IBAction)backItem:(id)sender{
[self.navigationController popViewControllerAnimated:YES];
self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 12;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
static NSString * strCell = @"cell";
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:strCell];
if(!cell){
cell = [[UITableViewCell alloc] initWithStyle:0 reuseIdentifier:strCell];
}
cell.textLabel.text = @" 来自夏日里的夏天的Xcode";
cell.textLabel.numberOfLines= 0;
cell.textLabel.font = [UIFont systemFontOfSize:15.0f];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;//设置cell的箭头
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return section==0?0:8;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath{
self.myTableView.estimatedRowHeight= 44.0f;
return UITableViewAutomaticDimension;
}
// 改变UITableView的headerView背景颜色为透明色
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section{
view.tintColor = [UIColor clearColor];
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath{
[self.myTableView deselectRowAtIndexPath:indexPath animated:YES];
}
tableview常用方法
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 一、cell的重用机制 1、why同样的cell会被创建很多次,这样很浪费系统的内存,既然是一样的,就可以拿来重复...
- tableView可以说是每个app中必不可少的控件,所以掌握流畅度优化技能相当的重要。 这里总结一些常用的优化技...