简体   繁体   中英

UITableViewCell async image loading layout

I am asynchronously loading images into my UITableView 's cells using AFNetworking 's categories on UIImageView as follows:

[cell.imageView setImageWithURL:menuItem.image_url placeholderImage:[UIImage imageNamed:@"placeholder"]];

My problem is that the cell loads fine with the placeholder image, but after the UITableView finishes loading, and I trigger a [cell layoutSubViews] by touching, scrolling, highlighting, etc, the cell pushes self.textLabel closer to self.imageView . Here's a series of images describing the behaviour:

状态1

状态2

状态2细节

This obviously ends up with non-uniform text. Am I even correct that it is the cell's layoutSubviews method that is getting called?

Well, this was dumb. I was right in that the cell's layoutSubviews method was getting called, so I subclassed UITableViewCell and implemented layoutSubViews myself and laid out self.imageView and self.textLabel myself. Sheesh.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM