我的xcode6上的UITableview SepartorInset全宽度问题

时间:2014-10-02 12:18:14

标签: ios uitableview xcode6

我正在使用xcode6.0.1。我的UIVIew Controller包含一个tableview,我需要设置分隔符插入全宽。我通过xib.But更改了我的tableview分隔符插入我无法在我的xcode6上获得分隔符插入的全宽(在我的xcode5分隔符中可以插入全宽)。如何解决此问题?

change tableview separator inset via xib

enter image description here

my tableview separator line like this(not get full width)

enter image description here

3 个答案:

答案 0 :(得分:2)

我解决了我的问题

-(void)viewDidLoad{

  self.tableView.layoutMargins = UIEdgeInsetsZero;

}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

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

答案 1 :(得分:0)

在iOS 8 [tableView setLayoutMargins:UIEdgeInsetsZero];

中使用此方法

答案 2 :(得分:0)

我猜你在iOS8中模拟你的应用程序,这是iOS8中的一个新属性“@property(nonatomic)UIEdgeInsets layoutMargins”。我建议你尝试创建一个UITableViewCell类类别(例如UITableViewCell + Separator)然后添加这个getter

- (UIEdgeInsets)layoutMargins
{
    return UIEdgeInsetsZero;
}

在iOS7中这不会被称为cos在SDK中没有这个属性,并且不会导致任何崩溃;在iOS8中,每次使用单元格时都会调用它

它对我有用