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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:43:59+00:00 2026-06-14T23:43:59+00:00

In my iPhone app I’m trying to programmatically resize and move a UIImageView in

  • 0

In my iPhone app I’m trying to programmatically resize and move a UIImageView in order to give it as origin the top-left corner of the iPhone screen and to have it to be both wide and tall as the height of the screen.
To do so I’m using with the following code:

-(void)viewDidLoad
{
     //Getting screen size
     CGRect screenSize = [[UIScreen mainScreen]bounds];

     //Creating the new frame for the UIImageView
     CGRect arect = CGRectMake(0, 0, screenSize.size.height, screenSize.size.height);
     //Setting the image to show

     UIImage *image = [UIImage imageNamed:@"Adele.jpg"];
     self.imageView.image = image;

     //Setting new frame and contentmode
     self.imageView.frame = arect;
     self.imageView.contentMode = UIViewContentModeScaleToFill;
}

self.imageView is an outlet I created with InterfaceBuilder.

Problem is that this code does not seem to have any effect on the frame of the UIImageView when I start the application. The imageview infact will be shown in the same position and with the same size that I set when I created it with IB.

Does anyone of you guys have an idea on why this code isn’t working? What am I missing?

  • 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-14T23:44:01+00:00Added an answer on June 14, 2026 at 11:44 pm

    I think you might need a different content mode.

    Give UIViewContentModeScaleAspectFit a try. In context:

    self.imageView.frame = arect;  
    self.imageView.contentMode = UIViewContentModeScaleToFill;
    

    If that doesn’t work you can initWithFrame:

    CGRect myImageRect = CGRectMake(0.0f, 0.0f, 320.0f, 109.0f);
    UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect];
    [myImage setImage:[UIImage imageNamed:@"myImage.png"]];
    

    source

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

Sidebar

Related Questions

My iPhone app formats an NSDecimalNumber as a currency using setCurrencyCode, however another screen
the iphone app I am writing shows white screen when first launched, but become
My iPhone app has an initial screen, then the main screen, and then a
developing iphone app, I have used a UIImageview and i have set an image
In iPhone App, Can we take pictures at some perticular time intervals programmatically by
my iPhone app uses OpenGL ES in full screen mode (the status bar is
In iPhone app, how do we edit a recorded video programmatically? Is there any
My iPhone app can't seem to use soft keyboards that doesn't use the US-like
my iphone app crashes unexpectedly and looking at the crash log I can't tell
The iPhone app that I am working on requires GET calls to a 3rd

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.