IOS8 设置TableView Separatorinset 分割线从边框顶端开始
在ios8上 [TableView
经过测试加入下面方法 在ios7 8上都可以正常工作
-(void)viewDidLayoutSubviews{
if ([self.shopTableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.shopTableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.shopTableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.shopTableView setLayoutMargins:UIEdgeInsetsZero];
}
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
}
本文介绍了一种解决iOS8中TableView分割线不显示在边框顶端的问题的方法。通过在viewDidLayoutSubviews方法中调用setSeparatorInset和setLayoutMargins方法,并确保其参数为UIEdgeInsetsZero,可以在iOS7和iOS8上实现一致的效果。
890

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



