对 tableViewCells 应用检查以隐藏 imageView
Posted
技术标签:
【中文标题】对 tableViewCells 应用检查以隐藏 imageView【英文标题】:Apply check on tableViewCells to hide imageView 【发布时间】:2014-11-19 10:43:15 【问题描述】:在我的
tableView
中,我有 5 个tableView
cells
。每个都有一个imageView
。 在tableView
之外,有一个UIButton
。UIButton
上面也有图片。 现在,我的问题是检查cells
上的图像是否隐藏。 清除问题,我需要检查所有单元格,如果 所有cells
上的imageView
是否隐藏。我试过这段代码:
for (int i=0; i<=4; i++)
if (cell.unlockImageView.hidden)
NSLog(@"calling if for hiding image");
我认为我的代码不正确,但我试了一下,但没有 工作。所以请建议我如何检查所有单元格上的 imageView 是否隐藏?
【问题讨论】:
【参考方案1】:试试下面的代码希望对你有帮助。
for (customTableViewCell* tblCell in tableView.visibleCells)
if (tblCell.unlockImageView.hidden)
NSLog(@"Imageview is hidden");
【讨论】:
谢谢,但没用。 ImageView 在所有单元格上都隐藏但它没有在日志中打印“Imageview is hidden”。 如果你在 if 条件之前使用 NSLog(@"%@",tblCell.unlockImageView) 那么你将在日志中获得所有信息 这是我在应用程序中尝试的代码,for (SayMoreTableViewCell* tblCell in tableView.visibleCells) NSLog(@"Imageview is hidden %@",tblCell.ulockImageView); if (tblCell.ulockImageView.hidden)
它也没有调用 for 循环。
你在 NSLog() 中得到了什么?
它正在像 0x797a7050 一样打印;帧 = (0 0; 320 519);隐藏=是;自动调整大小 = W+H;层 = 以上是关于对 tableViewCells 应用检查以隐藏 imageView的主要内容,如果未能解决你的问题,请参考以下文章
以编程方式将 UILabel 添加到自定义 tableViewCell
自定义 tableviewcell 动态高度未根据约束更新(以编程方式自动布局)