Używam niestandardowego UITableViewCell od stalówki. Widok akcesoriów to wskaźnik szczegółowych informacji. Problem polega na tym, że kolor tła obiektu UITableViewCell za widokiem akcesoriów nie jest renderowany (patrz obraz/źródło poniżej). Jakieś wskazówki? A oto kilka rzeczy, które próbowałem, ale nie działa:Jak uzyskać przezroczysty widok akcesoriów w UITableViewCell? (w/Screenshot)
Rzeczy, które nie działa:
- Ustawianie backgroundColor widoku akcesoriów do clearColor
- Ustawianie contentView.opaque komórki do FAŁSZ
- Ustawianie contentView.opaque tabeli widokiem na FAŁSZ
- ustalenie niż domyślny widok akcesoriów dla komórki
alt text http://www.chicknchoke.com/so/IMG_8028.png
-(void)showTablePrep
{
myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 480, 320, 416) style:UITableViewStylePlain];
myTableView.dataSource = self;
myTableView.delegate = self;
myTableView.delaysContentTouches = FALSE;
myTableView.opaque = FALSE;
myTableView.rowHeight = 60;
[UIView beginAnimations:@"SlideUp" context:nil];
[UIView setAnimationDuration:0.3f];
[myTableView setCenter:CGPointMake(myTableView.center.x, myTableView.center.y-436)];
[self.view addSubview:myTableView];
[self.view bringSubviewToFront:myTableView];
[UIView commitAnimations];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
FriendsCell* cell = [tableView dequeueReusableCellWithIdentifier:@"CustomCellID"];
if (cell == nil){
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"FriendsCellView" owner:self options:nil];
cell = (FriendsCell*)[nib objectAtIndex:0];
if(indexPath.row % 2 == 0){
cell.contentView.backgroundColor = [UIColor grayColor];
}else{
cell.contentView.backgroundColor = [UIColor lightGrayColor];
}
cell.accessoryView.backgroundColor = [UIColor clearColor];
cell.contentView.opaque = FALSE;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if(f
riendsCounter > indexPath.row){
cell.titleLabel.text = @"Label";
cell.descLabel.text = @"Description goes here";
}else{
cell.titleLabel.text = @"";
cell.descLabel.text = @"";
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
return cell;
}
Chciałem też wspomnieć, że istnieje naprawdę świetny przegląd dostosowywania 'UITableView' rysunek tutaj: http://cocoawithlove.com/2009/04/easy-custom-uitab leview-drawing.html – Alex
To działało dla mnie: komórka.backgroundView = init [[UIView alloc] init]; cell.backgroundView.backgroundColor = [UIColor yellowColor]; – joshaidan
@joshaidan Nie zapomnij zwolnić utworzonego widoku (chyba że używasz ARC): cell.backgroundView = [[[UIView alloc] init] autorelease]; – manicaesar