iphone - 我的 UITableViewCell 中的 UIImageView 在单击时更改大小

标签 iphone ios image uitableview resize

我的应用程序中有一个相当普通的 UITableView,用于以默认/标准方式显示图像和文本。第一次请求 UITableViewCell 时,我用占位符图像返回它并开始异步下载真实图像。下载完成后,我替换了占位符图像。

如果下载失败,占位符图像将保留。单击此类行会正常运行。如果下载成功,单击带有预期图像的行会导致 UIImageView 扩展到该行的高度(并且宽度按比例增加)。 UIImageView 永远不会恢复到正常大小。粗略地尝试设置 UIImageView 的框架并不能缓解神秘调整大小的问题。

// from my - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; method
// after boilerplate cell dequeuing code
cell.textLabel.text = [selectedNoun title];

// add placeholder image
UIImage *placeholderImage = [UIImage imageNamed:@"placeholder.png"];
cell.imageView.image = placeholderImage;
[cell.imageView setContentMode:UIViewContentModeScaleAspectFit];
//...
// If the image has been downloaded I set it
cell.imageView.image = iconDownloader.image;

这让我抓狂。它实际上只发生在我的应用程序的两个表之一中,但在比较它们的行或行之后我看不出有任何区别。希望以前有人遇到过这个问题。

谢谢!

编辑:我对我的解决方案没有很好的解释,只是说超过一定尺寸的图像似乎会导致这种行为,而使用实际缩略图(甚至比 UIImageView 的框架稍大的图像)不会表现出这种行为。

最佳答案

如果您有自定义的 UITableViewCell,请确保您的 UIImageView 未使用“imageView”命名

关于iphone - 我的 UITableViewCell 中的 UIImageView 在单击时更改大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8581364/

相关文章:

iphone - 如何删除 iPhone <button> 样式?

ios - Obj-C、CLS_LOG Crashlytics 日志记录未在 Xcode 控制台中显示调试输出?

html - CSS 将图像对齐到文本框的左侧

html - 图像上的文本和背景颜色叠加

iphone - 确定 UIView 的可用区域

iphone - 全屏背景纹理与 OpenGL 性能问题 (iPad)

ios - 如何快速将本地 JSON 文件加载到 uitableview 中?

iphone - iPhone 中非系统字体的名称

android - 如何在 android 中为不同的 2 密度(如 mdpi、ldpi、hdpi)使用 9 个补丁图像。?

ios - 在 iPhone 上学习图形/游戏