How do I get rid of TableView extra blank line split line?
We often encounter the following problem, TableView table view above the content is not many, but tableView to help the entire screen with a blank line split line is full:
Such as:
The code is as follows:
tableviewcontroller.m// test//// Created by on 15/1/25.// Copyright (c) 2015/HTTP Blog.csdn.net/yangbingbinga. All rights reserved.//#import "TableViewController.h" @interface Tableviewcontroller () @end @implementation tableviewcontroller-(void) viewdidload { [super Viewdidload]; } #pragma mark-table View data source-(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView { return 1;} -(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section { return 3;} -(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{ UITableViewCell *cell=[tableview dequeuereusablecellwithidentifier:@ "cell" forindexpath:indexpath]; return cell;} @end
You can see that there are only 3 rows of data, but show a lot of lines of blank split line, how to remove?
Method 1. Completely remove all the split lines, then customize a view height to a pixel on the cell to simulate the actual split line
2. Method Two, if you do not want to customize the split line, then a rough way, add a footerview can solve the problem code is as follows:
tableviewcontroller.m// test//// Created by on 15/1/25.// Copyright (c) 2015/HTTP Blog.csdn.net/yangbingbinga. All rights reserved.//#import "TableViewController.h" @interface Tableviewcontroller () @end @implementation tableviewcontroller-(void) viewdidload { [super viewdidload]; <span style= "FONT-SIZE:24PX;" ><strong>self.tableview.tablefooterview=[[uiview alloc]init];//key statements </strong></span> }# pragma mark-table view data source-(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView { return 1;} -(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section { return 3;} -(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{ UITableViewCell *cell=[tableview dequeuereusablecellwithidentifier:@ "cell" forindexpath:indexpath]; return cell;} @end
Below, look at the effect of the operation, to see if it is easy to solve it?
The source of this article: Http://blog.csdn.net/yangbingbinga
iOS Development Tips TableView Remove extra empty line splits and customize cell splitter lines