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