234567891011121314151617181920 |
-(void)viewdidlayoutsubviews { if ([self.mytableview Respondstoselector: @selector (setseparatorinset:] Span class= "Crayon-sy" >{ [self. Mytableview setseparatorinset: Uiedgeinsetszero]; } if ([self.mytableview Respondstoselector: @selector (setlayoutmargins :) ]) { [self. Mytableview setlayoutmargins: Uiedgeinsetszero]; }}- (void) tableView : (uitableview Span class= "crayon-t" >*) tableview Willdisplaycell: (UITableViewCell *) cell Forrowatindexpath: ( Nsindexpath *) Indexpat{ if ([cell respondstoselector:@selector(setlayoutmargins:) ]) { [cell setlayoutmargins: Uiedgeinsetszero]; } if ([cell respondstoselector:@selector(setseparatorinset: )]){ [cell setseparatorinset: Uiedgeinsetszero]; }} |
Method 2:
Using Uiappearance, it's a good idea to set the global default appearance when the program starts
objective-c
| 123456789 |
[[uitableview appearance] Setseparatorstyle: Uitableviewcellseparatorstylesingleline]; [[uitableview appearance] setseparatorinset: Uiedgeinsetszero]; [[UITableViewCell appearance] setseparatorinset: Uiedgeinsetszero] ; if ([uitableview Instancesrespondtoselector: @selector (setlayoutmargins :) ]) { [[uitableview appearance] setlayoutmargins: Uiedgeinsetszero]; [[UITableViewCell appearance] setlayoutmargins: Uiedgeinsetszero ]; [[UITableViewCell appearance] setpreservessuperviewlayoutmargins: NO] ;} |
IOS8 tableview separatorinset Cell split line left aligned, iOS7 method failed