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 9068397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:10:54+00:00 2026-06-16T17:10:54+00:00

I am trying to adjust the size of a background static UIImageView (from Nib

  • 0

I am trying to adjust the size of a background static UIImageView (from Nib file) for iPhone5 users. Unfortunately, the following code does not seem to make any difference on the background view’s size.

Does anyone know why? Thanks in advance for any help you can provide.

ViewController.m:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    device = appDelegate.deviceType;
    NSLog(@"The device platform is: %@", device);
    if ([[device substringToIndex:8] caseInsensitiveCompare: @"iPhone 5"] == NSOrderedSame) {
        [background sizeThatFits:CGSizeMake(320, 504)];
    }
    else {
        [background sizeThatFits:CGSizeMake(320, 416)];
    }
...
//Note: 'background' is declared in `ViewController.h` as, `IBOutlet` `UIImageView` *background, and is linked to the image view in ViewController_iPhone.xib 
  • 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-16T17:10:55+00:00Added an answer on June 16, 2026 at 5:10 pm

    A few thoughts:

    1. As demosten and shabzco suggested, I wouldn’t use a device name/description to determine coordinates (if nothing else, what about the iPhone 6, etc.);

    2. If you’re going to set the frame programmatically, I would suggest setting the background.frame property based upon the view controller’s view’s bounds rather than hard coding the size of the image view. That way, the background is adjusted to the appropriate size of the view controller’s view, not only regardless of device, but also regardless if that view controller is, at a later date, embedded as a child view controller of another container controller, etc. (E.g., what if you put your view in a navigation controller and tab bar controller, your own custom container controller, etc.). Also, don’t make assumptions about the size of the status bar or other graphical elements. Let iOS figure all of this out for you with simply:

      background.frame = self.view.bounds;
      
    3. Or better yet, if you’ve added the background image view to the NIB itself, set the autosizing mask and don’t change the frame programmatically at all. If you have autolayout turned off, just set the autosizing properties of your image view like so:

      auto sizing

    Bottom line, if you can, avoid explicit device name references in your code and avoid hard coded coordinates. To have hardcoded dimensions in your code will just make your app more fragile, susceptible to problems with new devices, new versions of iOS, embedding your view controller in additional container controllers, etc., and limits the reuse opportunities for your code.

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

Sidebar

Related Questions

I am trying to adjust the width of tabs from Window -> Preferences ->
I'm trying to adjust a jquery script to my needs and encountered the following
I am trying to adjust my htacess file to skip the rewrite rule if
I am trying to write an excel macro/VBA code to adjust a column's contents
I'm attempting to adjust the size of a UIImageView dependent on whether the device
I am trying to adjust text size so it can fill a certain space
I am trying to adjust the size of an image so that it fits
I am trying to adjust the size of the text in my UITextView so
So far I can only adjust the size of each PickerColumn manually through code,
I am trying to adjust the size of an array using Arrays.copyOf with import

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.