Changing Image on selected state of UITablView cell(在 UITablView 单元格的选定状态上更改图像)
问题描述
我创建了一个自定义单元格并添加了一个标签和图像,我的表格中有 4 行,每行有一个不同的图像,每行打开一个不同的视图控制器,所以,现在我需要的是点击我想改变图像的特定行我试过了,但它不起作用,所以请帮帮我.
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;
}
}
问候兰吉特
推荐答案
尝试在创建单元格时或在 tableView:willDisplayCell:forRowAtIndexPath:
方法中执行以下操作:
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 单元格的选定状态上更改图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 UITablView 单元格的选定状态上更改图像


基础教程推荐
- Android:对话框关闭而不调用关闭 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01