2015-12-22 35 views
0

我想顯示UITableview自定義單元格。但我的表格分隔符不按預期顯示。我附上截圖。uitableviewcell分隔線不顯示全寬

enter image description here

我試圖讓UIEdgeInsetZero但它並沒有奏效。任何人都可以幫我解決這個問題。

+0

無法反映約束和故事板 –

+0

設置你的好,你需要做'separatorInset'到**無**了'UITableView'並在自定義單元格中,您需要從底部放置1px高度的UIView。 –

回答

0

嘿,我所有的解決方案。

我重寫我的自定義UITableViewCell中的layoutSubviews和分隔符顯示正確。

- (void)layoutSubviews { 
[super layoutSubviews]; 

for (UIView *subview in self.contentView.superview.subviews) { 
    if ([NSStringFromClass(subview.class) hasSuffix:@"SeparatorView"]) { 
     subview.hidden = NO; 
    } 
} } 
1

enter image description here

敬請通過自定義更改分隔符插圖。謝謝。

2

設置separatorInsetUIEdgeInsetZero是不夠的iOS 8.您還應該設置表和單元格的layoutMargins屬性UIEdgeInsetZero

0

試試這個:

cell.layoutMargins = UIEdgeInsetsZero; 

cell.preservesSuperviewLayoutMargins = NO; 
0
-(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]; 
    } 
}