2014-12-27 56 views
0

我试图在故事板上设置对UITableView的约束。在编辑器 - >销号选项中,约束被禁用。在编辑器中禁用约束 - >

enter image description here

他们为什么不启用?

更新:Gabbler的意见正确地指出,的tableView是最上面的观点,你不用做就可以了针的动作。我设置约束的目的是为了在应用程序运行时将缺省的引导空间设置为缺省的tableView。请检查截图:

enter image description here

+0

Is Destination a tableViewController? – gabbler 2014-12-27 16:25:20

+0

是的,它是UITableViewController。 – Nitish 2014-12-27 16:25:48

+1

然后tableView是最上面的视图,你不必对它执行pin操作。 – gabbler 2014-12-27 16:28:52

回答

1

你在找什么是separatorInsetlayoutMargins。在viewDidLoad

self.tableView.layoutMargins = UIEdgeInsetsZero; 
self.tableView.separatorInset = UIEdgeInsetsZero; 

并添加此方法。

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

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

当然,会试试这个。但为什么会出现默认的领先空间? – Nitish 2014-12-27 16:47:44

+1

这是iOS8的一项新功能。在iOS 8中,Apple在UIView上添加了layoutMargins属性。 layoutMargins需要一个UIEdgeInsets值,它允许您明确定义您的视图可用于指导接口部分放置位置的空白。 – gabbler 2014-12-27 16:52:24