Ios UITableViewCell';的背景视图从UITableView的左边缘偏移

Ios UITableViewCell';的背景视图从UITableView的左边缘偏移,ios,ios7,uitableview,Ios,Ios7,Uitableview,当我使用UIImageView设置单元格的backgroundView时,在UITableView的左侧和backgroundView的左边缘之间有空间。为什么会这样 下面是在UITableViewCell上的子类中设置背景的代码: - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style r

当我使用
UIImageView
设置单元格的
backgroundView
时,在
UITableView
的左侧和
backgroundView
的左边缘之间有空间。为什么会这样

下面是在
UITableViewCell
上的子类中设置背景的代码:

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code

        self.contentView.backgroundColor = [UIColor clearColor];

        NSString *imageName = @"invite_bg";
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 502)];
        self.backgroundView = imageView;
        self.imageView.image = [UIImage imageNamed:imageName];
    }
}
使用此代码

if([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0)
{

}
else
{
   _tbl_time.separatorInset=UIEdgeInsetsZero;
}
if([[[UIDevice currentDevice]systemVersion]floatValue]<7.0)
{
}
其他的
{
_tbl_时间分离器设置=UIEdgeInsetsZero;
}
希望这对您有用。

使用此代码

if([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0)
{

}
else
{
   _tbl_time.separatorInset=UIEdgeInsetsZero;
}
if([[[UIDevice currentDevice]systemVersion]floatValue]<7.0)
{
}
其他的
{
_tbl_时间分离器设置=UIEdgeInsetsZero;
}

希望这对您有用。

我将图像设置为
self.imageView
而不是
imageView
。我将
imageView
作为子视图添加到
contentView
,现在它可以工作了

我将图像设置为
self.imageView
而不是
imageView
。我将
imageView
作为子视图添加到
contentView
,现在它可以工作了

您正在加载的图像中有空间吗?@Maverick没有,图像中没有空间。@ill\u always\u be\u a\u warriors添加屏幕截图以观察您的问题。实际上,开箱即用的UITableView上有一个15磅的插图。你可以在故事板界面上看到这种行为。哦,快!这可能就是问题所在:您正在加载的图像中是否有任何空间?@Maverick No,图像中没有空间。@ill\u always\u be\u a\u warriors添加屏幕截图以观察您的问题。实际上,开箱即用的UtableView上有一个15磅的插图。你可以在故事板界面上看到这种行为。哦,快!可能这就是问题所在:我刚刚尝试在TableView和TableViewCell上设置了
分隔符设置。两者都不起作用。@ill\u always\u be\u a\u战士添加屏幕截图和一些代码我刚刚尝试在TableView和TableViewCell上设置
分隔符设置。两者都不起作用。@ill\u always\u\u be\u战士添加屏幕截图和一些代码