在ios8上
[TableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];不起作用
经过测试加入下面方法
在ios7 8上都可以正常工作
在初始化tableView时
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.tableView setSeparatorInset:UIEdgeInsetsZero];
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.tableView setLayoutMargins:UIEdgeInsetsZero];
}
}
在初始化cell时加上
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
这个可以放在自定义cell时 写上
还可以在tableViewDelegate方法
- (void) tableView:(UITableView*)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndextPath*)indexPath
里改
本文介绍了一个在 iOS 8 中 TableView 分隔线边距设置失效的问题及解决方案。通过检查并调用特定的方法,确保在不同版本的 iOS 上正确地显示 TableView 的分隔线。
2742

被折叠的 条评论
为什么被折叠?



