Rex*_*ids 8 iphone interface-builder uitableview uikit
我从笔尖使用自定义UITableViewCell.附件视图是详细信息披露指示器.问题是附件视图后面的UITableViewCell的背景颜色没有被渲染(参见下面的图像/源代码).有线索吗?此外,这里有一些我尝试但没有工作的东西:
不起作用的东西:
- 将附件视图的backgroundColor
设置为clearColor - 将单元格
的contentView.opaque设置为FALSE - 将表视图的contentView.opaque设置为FALSE
- 为单元格设置非默认附件视图
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;
}
Run Code Online (Sandbox Code Playgroud)
Ale*_*lex 11
您正在为您的单元格绘制错误的背景颜色.阿UITableViewCell将布置成使得contentView与accessoryView坐在并排侧.(这样做是为了contentView可以剪裁其内容,使其不与配件视图重叠)问题不在于配件视图是不透明的,而是灰色背景根本不是在配件视图后面绘制的.
自定义背后绘制的背景的正确方法是自UITableViewCell定义它backgroundView.我没试过这个,但由于你只是改变颜色,你可以简单地将backgroundColor颜色设置backgroundView为你想要的颜色.
| 归档时间: |
|
| 查看次数: |
9541 次 |
| 最近记录: |