separatorInset不工作Xcode 6?

时间:2015-02-13 08:11:05

标签: objective-c xcode6

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

UITableViewCell  *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];



cell.textLabel.text = [self.arrayOfPlaces objectAtIndex:indexPath.row];
cell.textLabel.font = [UIFont systemFontOfSize:14.0];
cell.separatorInset = UIEdgeInsetsZero;

return cell;

1 个答案:

答案 0 :(得分:0)

从iOS 8开始,您需要设置layoutMargins来调整单元格分隔符。

[cell setLayoutMargins:UIEdgeInsetsZero]; 

由于此属性在iOS 7及更低版本中不可用,因此您需要在分配前进行检查。您可以使用respondsToSelector

if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
    [cell setLayoutMargins:UIEdgeInsetsZero];
}

或者在您的自定义单元格类中添加以下内容

-(UIEdgeInsets)layoutMargins
{
    return UIEdgeInsetsZero;
}

您需要保留cell.separatorInset = UIEdgeInsetsZero;才能使其与iOS 7兼容。