2012-10-15 54 views
0

这目前我的手机是什么样子:http://tinypic.com/view.php?pic=344uz2a&s=6自定义的UITableViewCell IOS

可以看出,由于某种原因,它拒绝以填补的backgroundColor白色的单元格的右侧部分。我不知道为什么或者什么问题可能会发生?

这就是我已经实现了我的TableView/Cells。在viewDidLoad中,我将整个tableView设置为clearColor以隐藏“emptyCells”。

- (void)viewDidLoad{ 

self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; 
tableView.backgroundColor = [UIColor clearColor]; 
} 

在下面的方法中,我尝试设置单元格backgroundColor。不幸的是,如上所述,它拒绝将whiteColor设置在单元格的右侧。

- (UITableViewCell *)tableView:(UITableView *)pTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
static NSString *CellIdentifier = @"SearchCell"; 
UITableViewCell *cell = [pTableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

if (cell == nil) 
{ 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
} 
Task *task = [self.searchResults objectAtIndex:indexPath.row]; 

UILabel *nameLabel = (UILabel *)[cell viewWithTag:1]; 
UILabel *bookLabel = (UILabel *)[cell viewWithTag:2]; 
UILabel *chapterLabel = (UILabel *)[cell viewWithTag:3]; 

[nameLabel setText:task.name]; 
[bookLabel setText:task.book.name]; 
[chapterLabel setText:task.chapter.name]; 

cell.backgroundColor = [UIColor whiteColor]; 
cell.contentView.backgroundColor = [UIColor whiteColor]; 
cell.backgroundView.backgroundColor = [UIColor whiteColor]; 

return cell; 
} 

任何想法?我错过了什么,或者我能做些什么来解决这个“颜色”问题?感谢名单的问候

回答

1

它看起来你需要设置附属视图的背景颜色,以及像这样:

self.accessoryView.backgroundColor = [UIColor whiteColor]; 

如果您仔细检查背景视图的界限,它可能不跨越整个表格单元格。

0

尝试

cell.backgroundView.backgroundColor = [UIColor whiteColor]; 

cell.backgroundView.layer.backgroundColor = [UIColor whiteColor].CGColor;