如何在iPhone的表格视图单元格中设置背景图像

如何在iPhone的表格视图单元格中设置背景图像,iphone,cocoa-touch,uitableview,background-image,Iphone,Cocoa Touch,Uitableview,Background Image,我要设置单元格的背景图像。我已经为表格视图中的单元格设置了背景图像。但是我想在表格视图单元格中为背景图像设置两个图像。我想为背景设置备用单元格 像 Image1- Cell 1, Cell 3, Cell 5, Etc., Imgae-2- Cell 2, Cell 4,Cell 6, Etc., 请引导我,给我一些样本链接 谢谢 您可以为均匀/不均匀行设置两个不同的单元格,如下所示 - (UITableViewCell *)tableView:(UITableView *)tabl

我要设置单元格的背景图像。我已经为表格视图中的单元格设置了背景图像。但是我想在表格视图单元格中为背景图像设置两个图像。我想为背景设置备用单元格

  Image1- Cell 1, Cell 3, Cell 5, Etc.,

  Imgae-2- Cell 2, Cell 4,Cell 6, Etc.,
请引导我,给我一些样本链接


谢谢

您可以为均匀/不均匀行设置两个不同的单元格,如下所示

- (UITableViewCell *)tableView:(UITableView *)tableView 
         cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{    
    static NSString *CellIdentifierEvenRows = @"MyCellEven";
    static NSString *CellIdentifierUnevenRows = @"MyCellUneven";
    UITableViewCell *cell;

    if (indexPath.row % 2) {
        cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierUnevenRows];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
                                           reuseIdentifier:CellIdentifierUnevenRows] autorelease];
            cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"uneven.png"] autorelease];
        }
    } else {
        cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierEvenRows];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
                                           reuseIdentifier:CellIdentifierEvenRows] autorelease];
            cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"even.png"] autorelease];
        }
    }

    return cell;
}

(未测试)

cell.backgroundView将是
cell.backgroundView=[[UIImageView alloc]initWithImage:[UIImageName:@“偶数.png”]]autorelease]