objective-c - uitableviewcell 分隔符在 ios 8 中移动

标签 objective-c ios8 separator tableviewcell

我正在以编程方式创建表格 View 和单元格。表格 View 单元格分隔符在 iOS 8 中移动,

enter image description here

即使我已经设置了:

-(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

同时检查 iOS 8 UITableView separator inset 0 not working了解更多信息

关于objective-c - uitableviewcell 分隔符在 ios 8 中移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25531258/

相关文章:

ios - UIView inputView 与 inputViewController

ios - iOS 7 上的尺寸等级

Xcode 7 GM - 隐藏分组 UITableViewController 中一行的分隔符

iphone - 未使用 Retina @2x 版本的图形

ios - 动态表中自定义单元格中的按钮 : how to know which row in action method?

objective-c - 管理 Mac Cocoa 应用程序中未处理的异常和崩溃

objective-c - 从 NSTableView 获取 stringValue

ios - iTunes Connect 无效的预发行火车。

cygwin 上的 makefile 缺少分隔符

带有分隔符的 Java/Swing Box 布局