Pixelcloud.nl

Mobile development

UINavigationBar background image – iOS 5.0

Posted on | October 17, 2011 | No Comments

While the earlier post works perfect for iOS versions of 4.3 and below, iOS 5 brings us new way to customize UI Interface elements, without the need to override the - (void)drawRect:(CGRect)rect method of an interface element. Fortunately older binaries with the above implementation still work due link-checking binaries build with iOS version below 5.0.

So how do we achieve the above in iOS 5.0. Behold the UIAppearance protocol.

Following the protocol we can set the background image of a UINavigationBar by accessing the appearance property and supplying a UIImage, like so:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed: @"my_uinavigationbar_image.png"] forBarMetrics:UIBarMetricsDefault];

Besides changing the background image the UIAppearance Protocol has more utility methods to change the way interface elements look. E.g changing the title appearance has just gotten a lot easier:


NSDictionary *textAttributes =
[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:@"my_custom_fontname" size:21], UITextAttributeFont,
[UIColor redColor], UITextAttributeTextColor,
nil];
[[UINavigationBar appearance] setTitleTextAttributes:textAttributes];

No since these methods are only available to devices with iOS 5 installed and if you want to support lower os versions you will have to protect these methods with some runtime check if they are available. e.g. by calling
if([instance respondsToSelector(@selector(iOS5_method))]{ //Safe to use iOS 5 method... }

I hope this post helps fellow programmers with the transition to iOS 5.

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Twitter
  • MySpace
  • NuJIJ

iTunes Connect says: invalid binary

Posted on | October 13, 2011 | No Comments

Recently i had some trouble getting my binary accepted by iTunes Connect, although the invalid binary error can have multiple causes, here a short tip which is worth checking first before you delve into editing your plist or entitlement files.

Apple has released iCloud recently and when creating a new distribution certificate in the developer portal will have it enabled by default. However if your application isn’t iCloud aware signing your application with such a profile will probably result in above message. When you receive a message from apple saying your binary was invalid, it includes a cause simular to this: invalid Code Signing Entitlements – The signature for your app bundle contains entitlement values that are not supported.

Specifically, value “” for key “com.apple.developer.ubiquity-kvstore-identifier” in is not supported.

Take the following step, which might solve your problem:

  • Log in to the dev portal.
  • Check your distribution certificate for the application your tried to upload.
  • If it is iCloud enabled, proceed with the following to correct this.
  • Create a new distribution certificate for your application name (this will invalidate the old one).
  • Make sure you deselect the iCloud checkbox
  • Clean and rebuild your project, make sure you sign with the new certificate.
  • Upload to iTunes Connect and see if this solved your problem
  • Share and Enjoy:
    • Print
    • Digg
    • del.icio.us
    • Facebook
    • Google Bookmarks
    • Twitter
    • MySpace
    • NuJIJ

    iPhone Development – UINavigationBar Background Image

    Posted on | June 5, 2010 | No Comments

    Most iPhone development projects work just fine without the need to customize the appearance of the navigationBar. But once in a while you probably would like to change the background of the navigationBar.

    Your RootViewController has acces to a NavigationItem, which has a property titleView. This view holds the title of your current active view in the navigationControllers stack. However setting the titleView to one of your customViews, will not take up the whole background of the NavigationBar. This is because the NavigationBar consists of not only the titleView, but also has room for the default back button an perhaps another UIButton at the right.

    If you want a custom background for your navigationBar, and still want to maintain the ability place custom labels on top of it, without having to worry about views disappearing behind the background you have set, the following snippet will help you to do just that.

    Open your application MyAppDelegate.m and place the following implementation above the implementation of our MyAppDelegate.



    //Overide the drawing of the background UINavigationBar
    @implementation UINavigationBar (image)
    - (void)drawRect:(CGRect)rect {
    UIImage *image = [UIImage imageNamed: @"my_navigation_bar_bg.png"];
    [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
    }
    @end

    What it does is, whenever the application tries to draw the navigationBar, it uses the image “my_navigation_bar_bg.png” as your source to draw the containing rect of the navigationBar. So all other UIElements are draw on top of this image. The default height of the navigationBar is 44 pixels. So an image of 320×44 will fill up the total space behind all navigationItems in this application.

    Share and Enjoy:
    • Print
    • Digg
    • del.icio.us
    • Facebook
    • Google Bookmarks
    • Twitter
    • MySpace
    • NuJIJ
    keep looking »