Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SimonBS

macrumors regular
Original poster
Dec 30, 2009
202
0
Hello,

I just updated my iPhone 3GS to iOS 5 and my Xcode to Xcode 4.3 with SDK 5. I did this to test if my applications are all working properly on iOS 5 and it turns out that my custom navigation bar is not looking correct.

I have attached two images showing how it is supposed to be (the orange bar from iOS 4.3) and how it is in iOS 5 (the one with the blue navigation bar)

When running the application I get two errors in the console:

Code:
*** ImageIO - could not find ColorSync function 'ColorSyncProfileCreateWithName'
*** ImageIO - could not find ColorSync function 'ColorSyncProfileCopyData'
I am not sure what these errors means.

Here is my code for the custom navigation bar and how I am setting the title on top of it.

In CustomUINavigationBar.h:

Code:
#import <Foundation/Foundation.h>

@interface CustomUINavigationBar : UINavigationBar {

}

@end
In CustomUINavigationBar.m:

Code:
#import "CustomUINavigationBar.h"

@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
    UIImage *image = [UIImage imageNamed:@"UINavigationBar_Background.png"];
    [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
This is how I add the title in the ViewController.m:

Code:
// Setting top title
[self setTitle:@"Program"];
UILabel *titleView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height)];
[titleView setText:@"Festivalens Program"];
[titleView setBackgroundColor:[UIColor clearColor]];
[titleView setFont:[UIFont fontWithName:@"Arial-BoldMT" size:21.0]];
[titleView setShadowColor:[UIColor colorWithRed:1 green:0.854 blue:0.592 alpha:1]]; // Light orange
[titleView setShadowOffset:CGSizeMake(0, -1)];
[titleView setTextAlignment:UITextAlignmentCenter];
[titleView setTextColor:[UIColor blackColor]];
[[self navigationItem] setTitleView:titleView];
[titleView release];
 

Attachments

  • Skærmbillede 2011-06-07 kl. 11.39.17.png
    Skærmbillede 2011-06-07 kl. 11.39.17.png
    199.1 KB · Views: 254
  • Skærmbillede 2011-06-07 kl. 11.39.27.png
    Skærmbillede 2011-06-07 kl. 11.39.27.png
    198.9 KB · Views: 187
Last edited by a moderator:
Seems it's trying to do some sort of ColorSync operation (obvious). Can you, perhaps, strip the colour profile from the image in question?
 
The colour profile embedded in the image is used by ColorSync to perform colour matching. As that appears to be the problem removing any colour profile might fix it.

Try the command-line sips tool with the --deleteColorManagementProperties option...
 
If im not mistaking, he meant, take the RGB color from the picture, and set it with hand :)
[UIColor colorWITHRGB something.];

Nope. I'm pretty sure the ColorSync errors prevent the image loading at all so you can't take the colour from it. If the OP tested whether image was nil before drawing I expect it would be.
 
The colour profile embedded in the image is used by ColorSync to perform colour matching. As that appears to be the problem removing any colour profile might fix it.

Try the command-line sips tool with the --deleteColorManagementProperties option...

I just tried the following:

Code:
Simon-Stvrings-iMac:navigationbar simonstoevring$ sips --deleteColorManagementProperties UINavigationBar_Background.png
/Users/simonstoevring/Dropbox/Xcode/NibeFestival-2012/resources/NavigationBar/UINavigationBar_Background.png
  /Users/simonstoevring/Dropbox/Xcode/NibeFestival-2012/resources/NavigationBar/UINavigationBar_Background.png
Simon-Stvrings-iMac:navigationbar simonstoevring$ sips --deleteColorManagementProperties UINavigationBar_Background@2x.png
/Users/simonstoevring/Dropbox/Xcode/NibeFestival-2012/resources/NavigationBar/UINavigationBar_Background@2x.png
  /Users/simonstoevring/Dropbox/Xcode/NibeFestival-2012/resources/NavigationBar/UINavigationBar_Background@2x.png

Then I removed the images from my Xcode project and added them again but it makes no difference.
 
I just tried removing my custom navigation bar class (CustomUINavigationBar.m and CustomUINavigationBar.h) from the project but I still get the errors in the console.

*** ImageIO - could not find ColorSync function 'ColorSyncProfileCreateWithName'
*** ImageIO - could not find ColorSync function 'ColorSyncProfileCopyData'
 
I just tried removing my custom navigation bar class (CustomUINavigationBar.m and CustomUINavigationBar.h) from the project but I still get the errors in the console.

Is anything else not working? If not then perhaps the console messages are not a big problem. Of course that would not explain why your custom nav bar is not working.
 
Is anything else not working? If not then perhaps the console messages are not a big problem. Of course that would not explain why your custom nav bar is not working.

Well my last tab (the one with three dots and says "Mere") does not working. When pushing it nothing happens. It's just linked to a view controller with a table view. Besides that everything else seems to work.
 
There are some comments in the release notes about changes regarding categories on UINavBar. In short there's a more compatible way to get a custom appearance for a navbar.
 
There are some comments in the release notes about changes regarding categories on UINavBar. In short there's a more compatible way to get a custom appearance for a navbar.

Ah, I just checked it.

In the iOS 5 beta, the UINavigationBar, UIToolbar, and UITabBar implementations have changed so that the drawRect: method is not called on instances of these classes unless it is implemented in a subclass. Apps that have re-implemented drawRect: in a category on any of these classes will find that the drawRect: method isn't called. UIKit does link-checking to keep the method from being called in apps linked before iOS 5 but does not support this design on iOS 5 or later. Apps can either:
  • Use the customization API for bars that in iOS 5 and later, which is the preferred way.
  • Subclass UINavigationBar (or the other bar classes) and override drawRect: in the subclass.

But I thought I did subclass the UINavigationBar and override the drawRect: subclass? :confused: Sorry, I'm still a bit green to iOS development.
 
I said you could ask if it wasn't under NDA. I did not say it was or wasn't, although I specifically said "not iOS 5.0". You then went and posted an issue only occurring on iOS 5.0. I would consider that to be under NDA.

Oh, I'm sorry. I misunderstood you then.
 
A category is not a subclass. The apple guys have always said that overriding existing methods in a category is "bad." I understand that if there doesn't seem to be another way and it seems to work with no problems then one may still do "bad" things. But they're still "bad." Anyway, figure out the "good" way to do this.
 
Yeah I noticed this in the Tweetbot app. After I upgraded to iOS 5 beta, their custom navigation bar's color was changed (looks bad now)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.