ios7中的UITableViewCell现在在左右两侧都有间隙

ios7中的UITableViewCell现在在左右两侧都有间隙,uitableview,ios7,indentation,custom-cell,Uitableview,Ios7,Indentation,Custom Cell,我有一个UITableView,在ios6中,我的自定义单元格完全伸展到屏幕的左右两侧。所以我手机左侧的方形图像紧靠着手机屏幕 但是,现在在ios7中,左侧出现了一个小间隙,因此图像现在远离侧面,并与单元格中的文本略微重叠 这似乎也发生在我现在在ios7中查看的其他应用程序中——所有应用程序的左边都有一个间隙,也许右边也有 根据Interface Builder,我的自定义单元格设置为320大小-ios 7未更改此设置吗?ios 7添加了一个separatorInset属性 尝试将其添加到UIT

我有一个UITableView,在ios6中,我的自定义单元格完全伸展到屏幕的左右两侧。所以我手机左侧的方形图像紧靠着手机屏幕

但是,现在在ios7中,左侧出现了一个小间隙,因此图像现在远离侧面,并与单元格中的文本略微重叠

这似乎也发生在我现在在ios7中查看的其他应用程序中——所有应用程序的左边都有一个间隙,也许右边也有

根据Interface Builder,我的自定义单元格设置为320大小-ios 7未更改此设置吗?

ios 7添加了一个separatorInset属性

尝试将其添加到UITableViewController:

将图像添加到cell.contentView可修复此问题:

[cell.contentView addSubview:imgView]


这样,您甚至不必考虑separatorInset属性。

适用于在c中使用Xamarin/MonoTouch的用户

tableView.SeparatorInset = UIEdgeInsets.Zero;

我宁愿自己做分离器。这感觉比使用tableview设置更简单。只需将分隔符设置为none,对单元格进行子类化,然后在init中执行此操作

-(id)initWithCoder:(NSCoder *)aDecoder{
    self = [super initWithCoder:aDecoder];
    if(self){

        UIView *seperator = [[UIView alloc] init];
        [seperator setBackgroundColor:[UIColor blackColor]];
        seperator.frame = CGRectMake(0, self.bounds.size.height-1, self.bounds.size.width, 1);
        [seperator setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth];
        [self.contentView addSubview:seperator];

    }
    return self;
}

这对我来说非常有效:

-(void)viewDidLayoutSubviews
{
    if ([self.Video_TableVIEW respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.Video_TableVIEW setSeparatorInset:UIEdgeInsetsZero];
    }

    if ([self.Video_TableVIEW respondsToSelector:@selector(setLayoutMargins:)]) {
        [self.Video_TableVIEW setLayoutMargins:UIEdgeInsetsZero];
    }
}

-(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];
    }
}

我试过了,但没有成功。我的表视图是用interface builder创建的,我尝试将您的代码插入表视图实现的各个位置,但没有成功ViewDiLoad、ViewWillDisplay等。如果我能帮上忙,我真的不想进行子类化,那么我是否缺少与您的方法相关的内容?如果您使用interface builder,然后选择表格视图,进入属性检查器,在标有分隔符插入的表格视图下找到所选内容,将下拉列表从默认更改为自定义,然后将左侧值从15更改为0。这似乎会更改每个部分插入的标题,但不在表格单元格内。我不确定是否理解。。。它应该使单元格分隔符从左到右一直伸展。如果只是设置UITableViewCell的textLabel文本属性,那么它仍将具有缩进。您只需创建一个新的文本标签并将其作为子视图添加到UITableViewCell的contentView中,就可以解决这个问题。我使用setSeparatorInset和Interface Builder的自定义插入尝试了这两种解决方案,但在iOS 7和iOS 8中,这两种解决方案似乎都不适用。差距仍然存在。我不确定该注释的意思,但我相信我发布的代码是正确的,因为在Xamarin中,这些属性被转换为字段,因此更易于使用。我想上面的评论没有意识到mono是什么。tableView.separatorInset=UIEdgeInsetsZero;对于obj-c tableView.SeparatorInset=UIEdgeInsets.Zero;单声道!问题是,在视网膜上显示的分隔带厚度为2px,而UITableView绘制的分隔带厚度仍为1px。我绕过了这个限制,定义了区分屏幕分辨率和绘制0.5px或1px线的逻辑,但这根本不是未来的证明。
-(void)viewDidLayoutSubviews
{
    if ([self.Video_TableVIEW respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.Video_TableVIEW setSeparatorInset:UIEdgeInsetsZero];
    }

    if ([self.Video_TableVIEW respondsToSelector:@selector(setLayoutMargins:)]) {
        [self.Video_TableVIEW setLayoutMargins:UIEdgeInsetsZero];
    }
}

-(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];
    }
}
 override func viewDidLoad() {
    super.viewDidLoad()

    tableView.cellLayoutMarginsFollowReadableWidth = false
 }