可是在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];
}
}
這樣,空白就沒有了