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

  • SEARCH
  • Home
  • 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 8710955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:45:29+00:00 2026-06-13T04:45:29+00:00

In my FirstViewController I have write this code for switch background if device is

  • 0

In my FirstViewController I have write this code for switch background if device is iPhone4 or iPhone5:

Filename:
bg-for5-568@2x.png
bg-for4@2x.png
bg-for4.png

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIImage *backgroundImage = [[UIImage alloc] init];
    if([[UIScreen mainScreen]bounds].size.height == 568)
    {
       backgroundImage = [UIImage imageNamed:@"bg-for5-568h"];
    }
    else
   {
       backgroundImage = [UIImage imageNamed:@"bg-for4"];
   }
   self.view.backgroundColor = [[[UIColor alloc] initWithPatternImage:backgroundImage] autorelease];
   [backgroundImage release];
}

When i lanch the app on my simulator, the background for iphone5 show double size, out of the view.

/* RESOLVED THANK YOU */

  • 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-06-13T04:45:31+00:00Added an answer on June 13, 2026 at 4:45 am

    I am not sure if this is the solution for this problem as I am missing some infos, but:

    At first: Strip the .png from your imageNamed: method. Since iOS4, you shouldn’t do this anymore. The next thing is: What are the Names of your image? Note that an iPhone5 has a retina display, and your image should be named bg-for5-568h@2x.png but referred in the sourcecode as bg-for5-568h.

    Besides that: In almost every case where your image isn’t a photograph, what you are doing is a bad idea. And even if it is a photograph, simply use the bigger image for the iPhone 4 and 4S as well. It’s not that much bigger, so the memory footprint isn’t a problem here! Have a look on UIImageView‘s contentMode property. You can use this to adjust the position of the larger image. You also might want to check UIImageViews clipSubviews property to clip the image if it isn’t fullscreen.

    Trust me, in my company we had a loot of hooks for stuff like ~ipad, ~iphone, ~2x and even stretchable images. And all these hooks worked fine till the date, apple announced something similar or simply a new device. So I decided to not do these kind of hooks anymore. They seem to be very helpful in the first place, but the trouble you get when there is something new on the market isn’t worth it!

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

Sidebar

Related Questions

I have this code: -(IBAction) doSomething{ FirstViewController *firstViewController = [[[FirstViewController alloc]init]autorelease]; [firstViewController.label1 setAlpha:1.00]; [firstViewController.label2
I have a firstviewcontroller and i want to call a secondviewcontroller; this secondviewcontroller has
I have this code that i did on Xcode 4.2 in a tabbed application
I have searched a lot about this topic and I can't get this code
I have declared this ivar in my ViewController.h #import <UIKit/UIKit.h> @interface FirstViewController : UIViewController
In my AppDelegate I have the following code: UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@FirstViewController
I have this: FirstViewController : SecondViewController *secondViewController = [[SecondViewController alloc] init]; [self.navigationController pushViewController:secondViewController animated:YES];
I have two view controllers name RootViewController and SecondViewController. In the FirstViewController I have
I have a class named FirstViewController which is a subclass of UIViewController and I
I have a custom class which I want to load inside the firstViewController and

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.