我正在以编程方式创建表格 View 和单元格。表格 View 单元格分隔符在 iOS 8 中移动,
即使我已经设置了:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return kSomeNumber;
}
我的应用程序是 ios7,我的手机是 ios8。可能是什么问题呢? 我不能使用仅适用于 ios8 的 cell.layoutMargins
最佳答案
自 iOS8 以来,我们有 layoutMargins,这会导致您的行。
如果您有自定义单元格,请添加此方法将其删除:
- (UIEdgeInsets)layoutMargins
{
return UIEdgeInsetsZero;
}
或者在你的 uitableviewcontroller 中添加这个:
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
为了支持 iOS7 需要 responsToSelector
关于objective-c - uitableviewcell 分隔符在 ios 8 中移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25531258/