0
我可以手動在我的uitableviewcells上添加一個'行分隔符'(現成的iOS不會爲此剪切它)。所以我創建UIViews數組,稱爲_separatorLines,我從各指數的uitableviewcells'內容查看我‘的cellForRowAtIndexPath’加一的UIView與爲什麼我不能在啓動後更改UITableViewCell的ContentView
UIView *v = [_separatorLines objectAtIndex:indexPath.row];
[cell.contentView addSubview:v];
然而,當我選擇一個單元格,我想所有其他細胞'行分隔符變成紅色。 在「didSelectRowAtIndexPath方法」我有:
{
for(unsigned int i = 0; i < _rowsInSection-1; i ++)
{
//make all other rows have a red content view
if(i != indexPath.row)
{
NSIndexPath *I = [NSIndexPath indexPathForRow:i inSection:1];
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:I];
UIView *separatingLineView = [_separatorLines objectAtIndex:I.row+1];
separatingLineView.backgroundColor = [UIColor redColor];
[cell.contentView bringSubviewToFront:separatingLineView];
[separatingLineView setNeedsDisplay];
[cell setNeedsDisplay];
[cell.contentView setNeedsDisplay];
}
}
[self setNeedsDisplay];
相反,我沒有看到uitableviewcells改變的內容查看。