Uitable split line

Source: Internet
Author: User

Uitable split line

When I got to iOS8, I found that uitable is getting useless. If I don't talk about it, let's take a look at the screenshot effect:

The expected results are:

1. Customize a cell with a yellow background; expect to overlay the entire table unit;

2. The unit split line is connected;


The differences between reality and ideal are as follows:

1. The entire unit cannot be horizontally filled with yellow cells;

2. No headers are pulled to the right of the split line;

3. I only spent three cells. There is no full space, and there is also a split line in the OS.


Here is my solution:

Solution 1:

Set the table margins: [tableView setLayoutMargins: UIEdgeInsetsMake (0, 0, 0, 0)];

This is a new feature of ios8. therefore, this problem does not exist on ios7.


Solution 2 and 3 are as follows:

Step 1: Set the partition line of the unified settings table to leave blank [tableView setSeparatorInset: UIEdgeInsetsMake (0, 1000, 0, 0)];

The split line is set to leave 1000 pixels blank, so that all the split lines are drawn out of the view, so that the split lines automatically completed by iOS are invisible.


Step 2: Leave the following blank for each cell:

[Cell setSeparatorInset: UIEdgeInsetsMake (0, 0, 0, 0)];
[Cell setLayoutMargins: UIEdgeInsetsMake (0, 0, 0, 0)];

In this way, we can return the cell split line to the view.


# Import "ViewController. h "# import" DemoCell. h "@ interface ViewController () {IBOutlet UITableView * tableView;} @ end @ implementation ViewController-(void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. // The following two key codes: <strong> [tableView setLayoutMargins: UIEdgeInsetsMake (0, 0, 0, 0)]; [tableView setSeparatorInset: UIEdgeInsetsMake (0, 1000, 0, 0)]; </strong> [tableView setSeparatorColor: [UIColor redColor];}-(void) didreceivemorywarning {[super didreceivemorywarning]; // Dispose of any resources that can be recreated .} -(NSInteger) tableView :( UITableView *) tableView numberOfRowsInSection :( NSInteger) section {return 3;}-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath {DemoCell * cell = (DemoCell *) [[[NSBundle mainBundle] loadNibNamed: @ "DemoCell" owner: self options: nil] lastObject]; // The following two key codes: <strong> [cell setSeparatorInset: UIEdgeInsetsMake (0, 0, 0, 0)]; [cell setLayoutMargins: UIEdgeInsetsMake (0, 0, 0, 0, 0)]; </strong> return cell;} @ end


Related Article

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.