iOS Development Tips TableView Remove extra empty line splits and customize cell splitter lines

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.