【发布时间】:2015-12-22 14:40:14
【问题描述】:
【问题讨论】:
-
你不能在故事板上显示约束并设置你的单元格
-
嗯,你需要将
separatorInset设置为 none 对于UITableView,并且在自定义单元格中,你需要放置距底部 1px 高度的 UIView。
标签: ios iphone uitableview
【问题讨论】:
separatorInset 设置为 none 对于UITableView,并且在自定义单元格中,你需要放置距底部 1px 高度的 UIView。
标签: ios iphone uitableview
将separatorInset 设置为UIEdgeInsetZero 对于iOS 8 是不够的。您还应该将表格和单元格的layoutMargins 属性设置为UIEdgeInsetZero。
【讨论】:
试试这个:
cell.layoutMargins = UIEdgeInsetsZero;
cell.preservesSuperviewLayoutMargins = NO;
【讨论】:
嘿,我得到了解决方案。
我在我的自定义 UITableViewCell 中覆盖 layoutSubviews 并且分隔符正确显示。
- (void)layoutSubviews {
[super layoutSubviews];
for (UIView *subview in self.contentView.superview.subviews) {
if ([NSStringFromClass(subview.class) hasSuffix:@"SeparatorView"]) {
subview.hidden = NO;
}
} }
【讨论】:
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
// Remove seperator inset
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
// Prevent the cell from inheriting the Table View's margin settings
if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
[cell setPreservesSuperviewLayoutMargins:NO];
}
// Explictly set your cell's layout margins
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
【讨论】: