UITableViewCell清晰背景 - 分组UITableView

时间:2011-07-21 17:10:25

标签: iphone uitableview

我正在尝试在分组表格中显示我的数据,如下所示:

enter image description here

正如您所看到的,我已通过在 viewDidLoad 中编写以下代码来清除表格的背景视图:

customerTable.backgroundView = nil;  

同样在我的 xib 中,我清除了桌子的背景。

cellForRowAtIndexPath 中,我为每个表格单元格设置了背景颜色。

cell.backgroundColor = [UIColor colorWithRed:255.0/255 green:235.0/255 blue:178.0/255 alpha:1];  

结果我得到了上面的输出。

我面临的问题是黑角我进入每个单元格。我知道它与细胞的背景有关,但没有什么对我有用。我还尝试清除单元格编写以下代码行的背景:

    cell.backgroundView = nil;  

6 个答案:

答案 0 :(得分:8)

尝试

customerTable.backgroundColor = [UIColor clearColor];
customerTable.opaque = NO;
customerTable.backgroundView = nil;

答案 1 :(得分:0)

试试这段代码......

customerTable.separatorColor = [UIColor clearColor];

答案 2 :(得分:0)

尝试

- (void)tableView: (UITableView*)tableView willDisplayCell: (UITableViewCell*)cell forRowAtIndexPath: (NSIndexPath*)indexPath

{

  cell.backgroundColor = [UIColor clearColor];

}

答案 3 :(得分:0)

试试吧:

将单元格背景视图设置为YourcellImage&细胞背景颜色以清除颜色。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath             
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) 
    {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];

        [cell setBackgroundColor:[UIColor clearColor]];
        UIImage *backgroundImage = nil;
        UIImageView *backgroundView = nil;
        backgroundImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"YourYellowCellImage"ofType:@"png"]];
        backgroundView = [[UIImageView alloc]initWithImage:backgroundImage];
        backgroundView.frame = CGRectMake(0, 0, 600, 80); // Over here give your cell size
        cell.backgroundColor = [UIColor clearColor];
        cell.backgroundView =backgroundView;

        [backgroundView release];   
   }
   //Over your set your Label Value    
   return cell;
}

答案 4 :(得分:0)

我遇到了同样的问题。并且了解它与细胞的背景无关。

问题在于tableview的背景导致了这个奇怪的角落,所以

self.tableview.backgroundColor = [UIColor clearColor];
viewWillAppear中的

将解决问题:)

答案 5 :(得分:0)

清除cellForRowAtIndex方法中的背景应该可以正常工作

[cell setBackgroundColor:[UIColor clearColor]];

还尝试清除viewWillAppear中的背景,如果发生奇怪的事情,请清除项目并重建。

相关问题