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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:06:47+00:00 2026-06-17T07:06:47+00:00

I’m attempting to adjust the size of a UIImageView dependent on whether the device

  • 0

I’m attempting to adjust the size of a UIImageView dependent on whether the device is an iPhone 5 (tall screen) or an earlier iPhone version (shorter screen). Below is my code. However when I run the app these instructions are ignored. I suspect the problem is caused by auto layout constraints. If I turn those constraints off the image is resized but that messes up the rest of my layout. Is there anyway to selectively override auto layout rather than turning it off?

CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {

    // code for 4-inch screen
    avatarImage.frame = CGRectMake(43, 372, 75, 75);



} else {

    // code for 3.5-inch screen
    avatarImage.frame = CGRectMake(43, 372, 50, 50);

}

EDIT

Below is an image of the problem I am trying to solve. I want the avatar image to resize proportionally until it fits in the smaller view. And I want to programmatically move the text field up and to the right of the label.

enter image description here

enter image description here

  • 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-17T07:06:49+00:00Added an answer on June 17, 2026 at 7:06 am

    One way to do this would be to programmatically alter your constraints. You can do this by:

    1. Create height and width constraints for your imageview by selecting the image view, and then in Xcode 5, clicking on the m button:

      enter image description here

      Or, in the prior versions of Xcode, by clicking on the center button:

      create constraints

    2. Make sure to change the other, secondary, constraints work permit the resizing of the imageview. For example, if you have a label to the right of this thumbnail image, you want to make sure that it is set up so the width of the label will adjust as the size of the image changes. Bottom line, you want to make sure you don’t have constraint conflicts when the app runs, because if you do have some conflicts, you may get a debugging message about having to break a constraint to make the app work, or worse, that the constraints are not satisfiable.

    3. Create IBOutlet references for your new height and width constraints. The easiest way is to show the assistant editor (so your associated .h files show up while you’re manipulating your storyboard) and then control-drag from the constraint to the .h file:

      create IBOutlets

    4. Then in your code, you can alter your constraints:

      CGRect screenBounds = [[UIScreen mainScreen] bounds];
      
      if (screenBounds.size.height >= 568) {
          self.widthConstraint.constant = 75;
          self.heightConstraint.constant = 75;
      } else {
          self.widthConstraint.constant = 50;
          self.heightConstraint.constant = 50;
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
I have a reasonable size flat file database of text documents mostly saved in
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites 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.