在ios8上 [TableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];不起作用
经过测试加入下面方法 在ios7 8上都可以正常工作
-(void)viewDidLayoutSubviews
{
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.tableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.tableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
}
}
-(void)tableView:(UITableView )tableView willDisplayCell:(UITableViewCell )cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
本文探讨了在iOS8系统中使用UITableView时遇到的setSeparatorInset方法不起作用的问题,并提供了解决方案。通过在viewDidLayoutSubviews方法中检查并设置separatorInset和layoutMargins,以及在tableView:willDisplayCell:方法中同样操作cell,可以实现TableView的分隔线和布局调整。
1万+

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



