2012-09-09 75 views
0

我已經在IB中設置了UITableView的行分隔符樣式和顏色,但是,當表加載分隔線時不可見。自定義UITableViewCell缺少行分隔符

我正在使用具有自定義超類的UITableView CustomTableView - 這是UITableView的子類。在這張表中,我也使用了自定義的UITableViewCell

我能想到的唯一問題是,如果我沒有在我的awakeFromNib方法中調用'超級'實現 - 但我這樣做是不可能的。

任何想法?

EDIT與代碼

我的表格單元是如下 - CustomDefaultCell.h> CustomPlainCell.h>的UITableViewCell

CustomDefaultCell.m

- (void)awakeFromNib 
{ 
    [super awakeFromNib]; 

    // Called when loaded from a nib. 
    // Override all default cell behaviour here. 
    // 
} 

CustomPlainCell.m

- (void)awakeFromNib 
{ 
    [super awakeFromNib]; 

    // Called when loaded from a nib. 
    // Override all default cell behaviour here. 
    // 
    // Normal background view 
    self.backgroundView = [[UIView alloc] initWithFrame:self.frame]; 
    self.backgroundView.backgroundColor = [UIColor whiteColor]; 

    // Selected background view 
    self.selectedBackgroundView = [[UIView alloc] init]; 
} 

- (void)setSelected:(BOOL)selected animated:(BOOL)animated 
{ 
    [super setSelected:selected animated:animated]; 

    // Configure the view for the selected state 
    // 
    // Background gradient 
    CAGradientLayer *selectedViewGradientLayer = [CAGradientLayer layer]; 
    selectedViewGradientLayer.frame = CGRectMake(1.0f, 0.0f, 320.0f, CGRectGetHeight(self.frame) + 1.0f); 
    selectedViewGradientLayer.colors = @[(id)[UIColor colorWithHue:0.0f saturation:0.0f brightness:0.57f alpha:1.0f].CGColor, (id)[UIColor grayColor].CGColor]; 

    [self.selectedBackgroundView.layer addSublayer:selectedViewGradientLayer]; 
} 
+0

你使用Quartz來繪製你的內容嗎? – 2012-09-09 14:31:26

+0

我有一個.xib文件,相應的.h和.m –

+0

我知道,但是.h和m中有什麼? (不要告訴我「裏面有代碼」!) – 2012-09-09 14:38:39

回答

0

最終我決定使用委託方法tableView:willDisplayCell:forRowAtIndexPath:,並且如果該單元格是「CustomPlainCell」的子類,請使用背景顏色添加1pt高的UIView

2

有同樣的問題,並認爲當在單元格原型類中重寫該方法時,我沒有調用[super layoutSubviews];