http://www.skyfox.org/ios7-tableview-separatorinset-ajust.html
ios7下
//ios8下的新方法
-(void)viewDidLayoutSubviews
{
if ([_iCoureseTabelViewrespondsToSelector:@selector(setSeparatorInset:)]) {
[_iCoureseTabelViewsetSeparatorInset:UIEdgeInsetsZero];
}
if ([_iCoureseTabelViewrespondsToSelector:@selector(setLayoutMargins:)]) {
[_iCoureseTabelViewsetLayoutMargins:UIEdgeInsetsZero];
}
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cellrespondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
if ([cellrespondsToSelector:@selector(setSeparatorInset:)]){
[cell setSeparatorInset:UIEdgeInsetsZero];
}
}
另外一种方法是
在cell init方法里加
if ([self respondsToSelector:@selector(setLayoutMargins:)])
{
self.preservesSuperviewLayoutMargins = NO;
self.layoutMargins = UIEdgeInsetsZero;
}
if ([self respondsToSelector:@selector(setSeparatorInset:)])
{
self.separatorInset = UIEdgeInsetsZero;
}