0

I have the following code running fine on iOS 6.0 and iOS 7.0 where we set a logo (UIImageView) on a header (UIView).

Upon upgrading to SDK iOS7.1. The following stops working, and I have absolutely no idea why.

// Header
header = [[UIView alloc] initWithFrame: CGRectMake(0, baseYPos, self.view.viewSize.width, 50)];
header.backgroundColor = [UIColor blackColor];
[self.view addSubview: header];

// LOGO
UIImageView *logo = [[UIImageView alloc] initWithFrame: CGRectMake(0, 0, header.viewSize.width, header.viewSize.height - 20)];
logo.image = [UIImage imageNamed: @"logo.png"];
logo.alpha = 1;
logo.contentMode = UIViewContentModeScaleAspectFit;
logo.center = ccp(header.center.x, header.center.y - baseYPos);
[header addSubview: logo];

Using revealapp.com. Viewing the app in iOS7.0, I see the UIImageView as a floating logo (3D view in Reveal) above the header. Viewing the same app in iOS7.1, the UIImageView is basically a blank, transparent box with no image.

I've tried the following, all to no avail:

  • declaring the UIImageView with initWithImage, and set the frame later
  • force opaque on 'logo' to be FALSE, and TRUE for header
  • instead of adding 'logo' as a subview to 'header', I added it to the parent view of both, inserting it as a subview above the header

None of this works. It looks as if Apple:

  • changed the way we set images in UIImageView

OR

  • changed the way we add UIImageView to a UIView parent

OR

  • I've coded this totally the wrong way

I haven't been able to find any release notes on 7.1 to suggest it's an SDK change - it also makes for bad SDK design - "won't somebody please think of the children!"

This issue has me pretty stumped, so any help would be met with eternal gratitude (as in Free BEER kind :D).

Thanks all!

snowbound
  • 1,692
  • 2
  • 21
  • 29
  • 1
    Hi! Have you checked in debugger if the `[UIImage imageNamed:@"logo.png"]` isn't `nil`? Possibly if you use asset catalogs, you might want to remove the extension in image name (but it's more like an assumption) – Alexander Kostiev Mar 16 '14 at 13:35
  • I also find it's not necessary to remove image extension if importing images into Asset Catalog from project folder because contents.json in the .imageset folder created will have the filename. In other words, you have flexibility to refer image with just name (logo) or full name with/without @2x (logo.png or logo@2x.png). – snowbound Mar 18 '14 at 13:21

1 Answers1

0

Adding 'logo' image to the Asset Catalogue (AC) solved the issue.

Prior to this, none of our images were part of AC other than launchimage and appCode. For whatever reason, iOS 7.1 didn't recognise the 'logo' image along with one other.

So I imported all of our images into AC to future proof any SDK changes - didn't think AC was mandatory, thought it was just a XCode 5 feature.

Thanks @Alexander Kostiev for the AC lead. Wish I could give more points to you!

This blog post also helped: https://www.iphonelife.com/blog/31369/unleash-your-inner-app-developer-managing-images-xcode-5-asset-catalogs

snowbound
  • 1,692
  • 2
  • 21
  • 29