2013-05-20 110 views
0

我已經在表格視圖中爲單元格設置了圖像,但是沒有顯示劃分單元格的行。我做錯了什麼?設置表格視圖單元格圖像

- (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年5月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] cell separator style:2 separator color:UIDeviceRGBColorSpace 0.67 0.67 0.67 1 2013-05-20 07:28:40.393 KFBNewsroom [1274:c07] cell separator風格:2分隔符顏色:UIDeviceRGBColorSpace 0.67 0.67 0.67 1

編輯:問題的屏幕截圖 enter image description here

編輯:我結束了通過添加一個像素線到我的圖像的底部解決問題。

+0

「我設置了圖像fo 「我的表格視圖中的單元格」你是在哪裏做的,我沒有在你的文章中看到它。 – rdelmar

+0

我設置了cell.backgroundView = image; – raginggoat

+0

對不起,錯過了。所以有什麼問題?你看不到那個圖像?目前尚不清楚分界線與你的問題有什麼關係。 – rdelmar

回答

0
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    return 50; 
} 

此委託方法用於增加tableview單元格的高度。 你可以試試這個。

+0

這也沒有工作。 – raginggoat

0

轉到XIB中的tableview屬性,檢查Separator是否被設置爲'None'。在這種情況下,你需要從編碼

yourTableView.separatorStyle=UITableViewCellSeparatorStyleSingleLine; 

使用廈門國際銀行

enter image description here

,或設置爲從下拉「單線」 ..您的tableView的

+0

試過了。該行仍然不顯示。 – raginggoat

0

套裝屬性增加你的tableView行高(不止你的圖像高度)

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    return 100; 
} 
+0

我試過了。 – raginggoat

+0

什麼是你的圖像的高度? – Rajneesh071

+0

更改分隔線的顏色.. – Rajneesh071

相關問題