2011-05-05 38 views
0

我不能将黑色背景分配给我的表的行或添加的ImageViews。 。(每行有多个imageViews背景是白色的总是这是我的代码:我不能将黑色背景分配给我的视图

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); 
+0

也许图像有白色背景? – 2011-05-05 13:17:08

+0

@Jan Gressmann不是图像没有边框,正如你可以在代码中看到的那样,它们位于20点的距离。 – aneuryzm 2011-05-05 13:18:32

+0

好的,尝试添加:cell.contentView.backgroundColor = [UIColor black];和cell.backgroundView.backgroundColor = [UIColor black]; – 2011-05-05 13:25:55

回答

0

没关系尝试添加:

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; 
}