Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting resizable UIImage to a UIImageView at viewDidLoad is ignored
    text
    copied!<p>I have a <code>UIImageView</code> with an image that I want to be stretchable. In order to achieve that I do the following in <code>viewDidLoad</code>:</p> <pre><code>-(void) buildResizableDescriptionAreaBackground { UIImage *image = [UIImage imageNamed:@"description_area_background"]; CGFloat top = ceilf(image.size.height / 2.0) - 1; CGFloat bottom = floorf(image.size.height / 2.0); CGFloat left = ceilf(image.size.height / 2.0) - 1; CGFloat right = floorf(image.size.height / 2.0); if ([image respondsToSelector:@selector(resizableImageWithCapInsets:)]) { image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(top, left, bottom, right)]; } else { image = [image stretchableImageWithLeftCapWidth:left topCapHeight:top]; } [self.descriptionAreaBackgroundImage setImage:image]; [self.descriptionAreaBackgroundImage setHighlightedImage:image]; } </code></pre> <p>When I debug this I make sure that the <code>descriptionAreaBackgroundImage</code> is not nil, not hidden, alpha = 1 and with the right frame. Also I make sure that the image is not nil, have the right size and that the resizable image is also not nil. And yet the image is not set to the UIImageView.</p> <p>If I do this at <code>viewDidAppear:</code> everything works fine. If I set a regular image (Not stretchable, even at <code>viewDidLoad</code>) everything works fine.</p> <p>As far as I know any setup that does not require superview or window can be done at <code>viewDidLoad</code>, so why isn't it working?</p>
 

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