奇怪的UITableViewCellStyleSubtitle + [cell imageView]行为 [英] Strange UITableViewCellStyleSubtitle + [cell imageView] behaviors

查看:34
本文介绍了奇怪的UITableViewCellStyleSubtitle + [cell imageView]行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题困扰了我一个月,而且我一直拒绝发布有关该问题的信息,但是我再也忍不住了.这是怎么回事:

This question's been bugging me for a month and i've been resisting posting about it, but I can hold out no longer. Here's what's going on:

我有一个带有 UITableViewCell s的应用程序,所有应用程序均初始化为 UITableViewCellStyleDefault .对于每一个图像,我都使用出色的SDWebImage包设置图像视图的图像,该软件包扩展了UIImageView,使其具有用于[UIImageView setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)image]的方法.

I have an app with UITableViewCells, all initialized as UITableViewCellStyleDefault. For each one, I am setting the image view's image using the excellent SDWebImage package, which extends UIImageView to have a method for [UIImageView setImageWithURL:(NSURL*)url placeholderImage:(UIImage*)image].

问题是在tableView上图像显示的宽度比实际显示的要窄,但是由于某种原因,选择一行使其具有正确的尺寸.在屏幕外滚动该行,然后在屏幕上滚动,然后在屏幕外滚动也是如此.

The problem is that the images are showing up more narrow than they should be, on the tableView, but for some reason selecting a row makes it the correct size. So does scrolling the row off screen, then onscreen, then offscreen.

我应该使用什么方法来迫使细胞重绘?我发现了一些相互矛盾的想法,但到目前为止,这些想法都没有奏效.我觉得我缺少对UITableView到UITableViewCell的简单调用.另外,我在哪里打这个电话?我已经尝试在 cellForRowAtIndexPath willDisplayCell 中调用.

What method should I be using to force cells to redraw? I have found a few conflicting ideas and none of them have worked so far. I feel like there's a simple call to UITableView to UITableViewCell I'm missing out on. Also, where do I put this call? I have tried calls in cellForRowAtIndexPath and willDisplayCell .

感谢您的帮助!

SDWebImage: https://github.com/rs/SDWebImage

SDWebImage: https://github.com/rs/SDWebImage

推荐答案

我解决了这个问题-我只需要使我的 SDWebImage 占位符图像与我尝试的图像具有相同的宽高比加载.当我的服务器将所有图像强制设置为95x95时,这是一个相对容易的解决方案.我只是将我的 placeholder.png 更新为95x95(而不是92x132这样的奇怪尺寸)

I solved the issue - I had to just make my SDWebImage placeholder images the same aspect ratio as the images I'm trying to load. As my server forces all my images to be 95x95, this was a relatively easy fix; I simply updated my placeholder.png to also be 95x95 (instead of some odd dimension it was, like 92x132)

这篇关于奇怪的UITableViewCellStyleSubtitle + [cell imageView]行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆