Ios 我能';不要为我的视图指定黑色背景

Ios 我能';不要为我的视图指定黑色背景,ios,ipad,Ios,Ipad,我无法将黑色背景指定给表中的行或添加的ImageView。(每行有多个图像视图。背景始终为白色。这是我的代码: UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdent

我无法将黑色背景指定给表中的行或添加的ImageView。(每行有多个图像视图。背景始终为白色。这是我的代码:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

// Configure the cell...
cell.textLabel.text = [self wordAtIndexPath:indexPath];
cell.accessoryType = UITableViewCellEditingStyleNone;
cell.backgroundColor = [UIColor colorWithRed: 0.0 green: 0.0 blue: 0.0 alpha: 1.0];

//NSString *url = self.imageURL;
//dispatch_queue_t callerQueue = dispatch_get_current_queue();

dispatch_queue_t downloadQueue = dispatch_queue_create("Flickr downloader in Photo", NULL);
dispatch_async(downloadQueue, ^{
    NSData *image = [FlickrFetcher imageDataFromPhotoId:@"2654899252"];
    NSData *image2 = [FlickrFetcher imageDataFromPhotoId:@"2654072649"];
    NSData *image3 = [FlickrFetcher imageDataFromPhotoId:@"2654072293"];        /*dispatch_async(callerQueue, ^{
        processImage(imageData);
    });*/

    UIImageView *imageView = nil;

    if(image) imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithData: image]];

    UIImageView *imageView2 = nil;
    if(image2) imageView2 = [[UIImageView alloc] initWithImage:[UIImage imageWithData: image2]];

    UIImageView *imageView3 = nil;
    if(image3) imageView3 = [[UIImageView alloc] initWithImage:[UIImage imageWithData: image3]];

    imageView.frame = CGRectMake(0.0, 0.0, 220, 200);
    imageView2.frame = CGRectMake(240.0, 0.0, 220, 200);
    imageView3.frame = CGRectMake(480.0, 0.0, 220, 200);

    imageView.backgroundColor = [UIColor colorWithRed: 0.0 green: 0.0 blue: 0.0 alpha: 1.0];
    imageView2.backgroundColor = [UIColor colorWithRed: 0.0 green: 0.0 blue: 0.0 alpha: 1.0];
    imageView3.backgroundColor = [UIColor colorWithRed: 0.0 green: 0.0 blue: 0.0 alpha: 1.0];



    [cell addSubview:imageView];
    [cell addSubview:imageView2];
    [cell addSubview:imageView3];

    [imageView release];
    [imageView2 release];
    [imageView3 release];
});
dispatch_release(downloadQueue);
好的,请尝试添加:

cell.contentView.backgroundColor = [UIColor blackColor];
cell.backgroundView.backgroundColor = [UIColor blackColor];
通过将tableView.separatorStyle设置为
UITableViewCellSeparatorStyleNone

您的ViewController中应该有一个
UITableView
。如果您使用的是
UITableViewController
,请在viewDidLoad方法中设置属性:

-(void) viewDidLoad {
    [super viewDidLoad];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}

可能图像有白色背景?@Jan Gressmann否图像没有边框,正如您在代码中看到的,它们位于20个距离点处。好的,请尝试添加:cell.contentView.backgroundColor=[UIColor black];和cell.backgroundView.backgroundColor=[UIColor black];@Jan Gressmann表示方法“+black”找不到,我现在尝试使用RGB值。确定最后cell.contentView完成了任务。您知道如何删除单元格的边框(分隔每行的水平线)?