【发布时间】:2011-09-12 15:55:45
【问题描述】:
这个问题很简单,但很烦人。我将 groupe 样式 UITableView 放在视图控制器中,并使控制器成为表视图的委托和数据源。
当我改变表格背景的颜色时,我使用:
UIColor *backColor = [UIColor colorWithRed:(15.0 / 255.0) green:(170.0 / 255.0) blue:(230.0 / 255.0) alpha: 0.75f];
[self.myTable setBackgroundColor:backColor];
在tableView:tableView cellForRowAtIndexPath:indexPath 方法中,我只返回一个简单的单元格:
static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:moreCellIdentifier] autorelease];
}
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
return cell;
但奇怪的是每个单元格的圆角颜色都不对,我认为这是因为单元格的子视图之一的框架比单元格大,我试图制作框架的子视图很小但仍然失败。有什么想法吗?谢谢。
【问题讨论】:
-
我认为这是单元格宽度的问题,我继承了 UITableViewCell 并将新的单元格类设置为宽度仅为 200,但在表格视图中,单元格仍然占据几乎整个屏幕宽度。
标签: iphone uitableview colors background