Tôi sử dụng một UITableViewCell tùy chỉnh từ một ngòi bút. Chế độ xem phụ kiện là Chỉ báo tiết lộ chi tiết. Vấn đề là màu nền của UITableViewCell phía sau khung nhìn phụ kiện không được hiển thị (xem hình ảnh/nguồn bên dưới). Bất kì manh mối nào? Ngoài ra, đây là một số điều mà tôi đã cố gắng nhưng đã không làm việc:Làm thế nào để có được Xem phụ kiện trong suốt trong UITableViewCell? (w/Ảnh chụp màn hình)
Những điều đó đã không làm việc:
- Thiết lập backgroundColor của quan điểm phụ kiện để clearColor
- Thiết lập contentView.opaque của tế bào để FALSE
- Thiết lập contentView.opaque của bảng Xem FALSE
- Đặt chế độ xem phụ kiện không mặc định cho các tế bào
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;
}
Tôi cũng muốn đề cập rằng có một tổng quan thực sự tuyệt vời về việc tùy chỉnh bản vẽ 'UITableView' tại đây: http://cocoawithlove.com/2009/04/easy-custom-uitab leview-drawing.html – Alex
Làm việc này cho tôi: ô.backgroundView = [[Phân bổ UIView] init]; cell.backgroundView.backgroundColor = [UIColor yellowColor]; – joshaidan
@joshaidan Đừng quên phát hành chế độ xem bạn đã tạo (trừ khi bạn sử dụng ARC): cell.backgroundView = [[[UIView alloc] init] autorelease]; – manicaesar