Note that there are some explanatory texts on larger screens.

plurals
  1. POUIImageView size doesn't update until out of sight
    primarykey
    data
    text
    <p>I'm trying to make an image 100% the height of the cell, but it doesn't seem to update correctly.</p> <p>I have created a special <code>getCellHeightFromData</code> method that is meant to calculate the height from the text length. I also have a method called <code>getRestaurantPictureById</code> that downloads an image from a web server which responds with an image resized to the specific width and height, and returns it as an <code>UIImage</code>.</p> <p>I want to set the <code>UIImageView</code> to the same width and height as the image that was loaded. I have access to both the width and height as float numbers, so that is not the problem.</p> <h3>The UIImageView outlet looks like this</h3> <pre><code>@property (weak, nonatomic) IBOutlet UIImageView *Thumbnail; </code></pre> <h3>My attempt at resizing the image (from inside my UITableViewCell subclass)</h3> <pre><code>- (void)updateCellWithContent:(RestaurantCell*)restaurant { self.NameLabel.text = [restaurant name]; float width = 75.0; float height = [RestaurantCell getCellHeightFromData:restaurant]; self.Thumbnail.frame = CGRectMake(self.Thumbnail.frame.origin.x, self.Thumbnail.frame.origin.y, width, height); self.Thumbnail.image = [DataLoader getRestaurantPictureById:restaurant.restaurantId withWidth:width andHeight:height]; } </code></pre> <p>It does not look correctly immediately when I run, but if I scroll so that a cell goes out of sight, and then let it bounce back, it has been redrawn with the proper (100%) height.</p> <h3>Before scrolling out of sight</h3> <p><img src="https://i.stack.imgur.com/x8vHP.png" alt="Before"></p> <h3>After scrolling the first cell out of sight and letting it bounce back</h3> <p><img src="https://i.stack.imgur.com/lOPAd.png" alt="enter image description here"></p> <p><strong>Any ideas? Thanks in advance :)</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload