我的应用程序中有一个相当普通的 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/