本文介紹了在 UITablView 單元格的選定狀態(tài)上更改圖像的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
我創(chuàng)建了一個自定義單元格并添加了一個標簽和圖像,我的表格中有 4 行,每行有一個不同的圖像,每行打開一個不同的視圖控制器,所以,現(xiàn)在我需要的是點擊我想改變圖像的特定行我試過了,但它不起作用,所以請幫幫我.
I have a created a custom cell and added one label and Image, I have 4 rows in my table each row has a different image and each row opens a different view controller, so, now what I need is on click of a particular row I want the image to change to do that I tried this, but its not working, so please help me out.
if(indexPath.row == 0)
{
if(cell.selected == true)
{
UIImage *cellImage = [UIImage imageNamed:@"abc.png"];
cell.icon.image = cellImage;
}
else
{
UIImage *cellImage = [UIImage imageNamed:@"abc.png"];
cell.icon.image = cellImage;
}
}
問候蘭吉特
推薦答案
嘗試在創(chuàng)建單元格時或在 tableView:willDisplayCell:forRowAtIndexPath:
方法中執(zhí)行以下操作:
Try to do following when creating your cell or in tableView:willDisplayCell:forRowAtIndexPath:
method:
cell.imageView.image = [UIImage imageNamed:@"abc.png"];
cell.imageView.highlightedImage = [UIImage imageNamed:@"abc.png"];
如果它是 UIImageView
這篇關于在 UITablView 單元格的選定狀態(tài)上更改圖像的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!