2014-02-25 77 views
0

如何在tableview和單元格之間添加圖像?我的意思是,這個圖像應該在單元格下,但在tableview下面。我添加一個圖像,但它不是常量,當滾動更改其位置更改爲單元格。我想要一個常量圖像在tableview中,我也添加一個圖像self.view但當細胞來了,圖像低於細胞如何在tableview和單元格之間添加圖像

回答

0

你的問題很混亂。據我所知你想添加圖像作爲UITableview的背景,並且該圖像不會受到表格滾動的影響。

解決方案:爲您的單元格設置清晰的背景色,並將您的圖像添加爲Tableview的背景,如下所述。

在viewDidLoad中添加以下代碼

UIImageView *tempImageView = [[UIImageView alloc] 
           initWithImage:[UIImage imageNamed:@"iPhone.jpg"]]; 
[tempImageView setFrame:self.tableView.frame]; 
self.tableView.backgroundView = tempImageView; 

添加以下方法清除的UITableViewCell的背景色。

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    cell.backgroundColor = [UIColor clearColor]; 
} 

希望這會有所幫助。快樂編碼:)

+0

是啊有點改變它的工作,我看起來是「self.tableView.backgroundView = tempImageView;」謝謝@pratik Mistry! UIImageView * tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@「logoend.png」]]; UIView * logoView = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.checkinsTable.frame.size.width,self.checkinsTable.frame.size.height)]; [logoView addSubview:tempImageView]; tempImageView.frame = CGRectMake(55,100,50,50); self.checkinsTable.backgroundView = logoView; – user3236289

+0

不客氣! –

相關問題