Transferred from: http://blog.csdn.net/ljb_wh/article/details/40788333
iOS7 when the storyboard set TableView separator intend = 0 allows the tableview of the split bar to the top of the head.
However, when IOS8 was upgraded, the discovery did not work.
After Google, found the answer in StackOverflow
Translation record
IOS8 introduced the Layoutmargins attribute in both the cell and the TableView, and this attribute is not available in iOS 7, so you need to treat these two versions differently.
Use the Ricky scheme to set the Layoutmargin property in the cell:
-(void)TableView:(UITableView *)TableView Willdisplaycell:(UITableViewCell *)Cell Forrowatindexpath:(Nsindexpath *)Indexpath
{
If ([Cell Respondstoselector:@selector(Setseparatorinset:)]) {
[Cell Setseparatorinset:Uiedgeinsetszero];
}
If ([cell respondstoselector : @selector (setlayoutmargins:)]) {
[cell Setlayoutmargins:uiedgeinsetszero
}
//According to the author's final meaning, add the following paragraph
If([cell respondstoselector: @selector(setpreservessuperviewlayoutmargins:)]) {
[Cell Setpreservessuperviewlayoutmargins:no];
}
}
You also need to set the same properties in TableView. Through many experiments, I found that you can set this property in Viewdidlayoutsubviews.
Copy the following code into the implementation of your view
-(void)Viewdidlayoutsubviews
{
[SuperViewdidlayoutsubviews];
If ([Self.TableView Respondstoselector:@selector(Setseparatorinset:)]) {
[Self.TableView Setseparatorinset:Uiedgeinsetszero];
}
If ([Self.TableView Respondstoselector:@selector (setlayoutmargins< Span class= "pun" >:)]) {
[self. tableview setlayoutmargins: Uiedgeinsetszero];
} } /span>
In this way, it is possible to achieve the need for split-bar head in Ios7,ios8. (Translator: IOS6 default is the head, so this scheme can be applied to ios6-8).
Edit: As @bffmike says on Twitter, you may also need to set preservessuperviewlayoutmargins=no in the cell. Again: Everyone's situation is different.
IOS8 UITableView split bar Setting Separator Intent = 0 does not work