Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6726921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:59:12+00:00 2026-05-26T09:59:12+00:00

How can I execute code only for iOS 5 with iOS<5 compatibility? I have

  • 0

How can I execute code only for iOS 5 with iOS<5 compatibility? I have written this code:

 BOOL isIOS5 = [[[UIDevice currentDevice] systemVersion] floatValue] > 4.3;
 if (isIOS5) {

    [[UINavigationBar appearance]setBackgroundImage:[UIImage imageNamed:@"cabecera.png"] forBarMetrics:UIBarMetricsDefault];
    [[UINavigationBar appearance]setTintColor:[UIColor colorWithRed:80.0f/255.0f green:150.0f/255.0f blue:185.0f/255.0f alpha:1]];

 }

If I execute the app in iOS 5 it works fine, but if I try to execute the app in iOS <5 emulator it breaks. Is there a way to write an app who has code only for iOS5 but ignores it when iOS<5?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:59:13+00:00Added an answer on May 26, 2026 at 9:59 am

    In your case, you should check if the method is available in the current iOS Version:

    if([UINavigationBar respondsToSelector:@selector(appearance)]) //iOS >=5.0
    {
        [[UINavigationBar appearance]setBackgroundImage:[UIImage imageNamed:@"cabecera.png"] forBarMetrics:UIBarMetricsDefault];
        [[UINavigationBar appearance]setTintColor:[UIColor colorWithRed:80.0f/255.0f green:150.0f/255.0f blue:185.0f/255.0f alpha:1]];
    }
    

    Please also see this question/answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I execute only code? I have a huge bundle (about 1000 images)
I have a problem similar to this one: How can I execute code after
I know that from iOS 4.0 onwards we can execute our code in background.
How can I make JavaScript (or jQuery) code only execute on the visitor's first
How can I execute some code, once a day. e.g. call MyMethod() at 3pm
What do you call a programming language that can execute its own code (passed
I can do an eval(something()); to execute the code dynamically in JavaScript. Is there
using register_shutdown_function I can register code to execute at the end of a PHP
To test if i can connect to my database, I execute the following code
Can the CLR 4.0 execute CLR 2.0 IL without the need for source code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.