可是在ios8中,设置setSeparatorInset:UIEdgeInsetsZero 已经不起做用了。下面是解决办法java
首先在viewDidLoad方法加入如下代码:ios
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {spa
[self.tableView setSeparatorInset:UIEdgeInsetsZero];.net
}代理
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {blog
[self.tableView setLayoutMargins:UIEdgeInsetsZero];it
}io
而后在UITableView的代理方法中加入如下代码
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPathtable
{class
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
这样,空白就没有了