[英]Setting Table View Cell Image
我已經在表格視圖中為單元格設置了圖像,但是沒有顯示划分單元格的線。 我做錯了什么?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *mbTableIdentifier = @"SimpleTableItem";
UIImageView *image = [[UIImageView alloc]init];
image.image = [UIImage imageNamed:@"BarButton.png"];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:mbTableIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:mbTableIdentifier];
cell.textLabel.font=[UIFont systemFontOfSize:16.0];
}
// cell.backgroundView = [[CustomCellBackground alloc] init];
cell.selectedBackgroundView = [[CustomCellBackground alloc] init];
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.textLabel.highlightedTextColor = [UIColor darkGrayColor];
cell.textLabel.textColor = [UIColor whiteColor];
cell.backgroundView = image;
cell.textLabel.text = [mbTableData objectAtIndex:indexPath.row];
return cell;
}
編輯:我記錄了我的分隔符樣式和顏色
2013-05-20 07:28:40.392 KFBNewsroom [1274:c07]單元格分隔符樣式:2個分隔符顏色:UIDeviceRGBColorSpace 0.67 0.67 0.67 1 2013-05-20 07:28:40.393 KFBNewsroom [1274:c07]單元格分隔符樣式:2分隔符顏色:UIDeviceRGBColorSpace 0.67 0.67 0.67 1 2013-05-20 07:28:40.393 KFBNewsroom [1274:c07]單元格分隔符樣式:2分隔符顏色:UIDeviceRGBColorSpace 0.67 0.67 0.67 1
編輯:問題的屏幕截圖
編輯:我最終解決了問題,在我的圖像底部添加了1個像素行。
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 50;
}
此委托方法可增加表視圖單元格的高度。 您可以嘗試一下。
轉到XIB中的tableview屬性,檢查Separator是否已設置為“ None”。 在這種情況下,您需要從下拉菜單中將其設置為“單行”。
通過編碼設置tableView的屬性
yourTableView.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
使用XIB
或增加tableView行的高度(然后增加圖像的高度)
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 100;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.