2014-05-20 85 views
0

我到处搜索,但无法找到这个问题的答案。摆脱从UITableView的左侧空间

在我的UITableView的单元格中,左侧有空白区域。我如何摆脱它?

这是我发起UITableView对象:

listTableView = [[UITableView alloc] initWithFrame:CGRectMake(20, 60, _tableWidth, _tableheight) style:UITableViewStylePlain]; 

table view

回答

5

这应做到:

listTableView.separatorInset = UIEdgeInsetsZero; 
+0

工作完美..谢谢!! – Inder

+0

不适用于我,我将子视图添加到UITableViewCell,而不是设置labelText。 – ideawu

0

如果要治理的是为textLabel的插图和分隔符 您需要继承UITableViewCell

@interface CustomTableViewCell : UITableViewCell 
@end 
@implementation CustomTableViewCell 

- (void)layoutSubviews 
{ 
    [super layoutSubviews]; 

    CGRect frame = self.textLabel.frame; 
    frame.origin.x = 5; 
    self.textLabel.frame = frame; 

    // available only from iOS7 
    if ([self respondsToSelector:@selector(setSeparatorInset:)]) { 
     self.separatorInset = UIEdgeInsetsZero; 
    } 
} 

@end