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

The Archive Base Latest Questions

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

In my iphone app i need to set image in the image view. the

  • 0

In my iphone app i need to set image in the image view.

the image view height is always 100pixels.

we need to set the width of the image view with respect to the original image scale ratio.

ie per suppose width X height of an image is 300×400 (original) (4×3)

our displayed image view image size would be 75X100

width X height of an image is 512×512 (original) (1×1)

our displayed image view image size would be 100X100

width X height of an image is 128 x 256 (original) (1×2)

our displayed image view image size would be 50X100

in all those cases image view height 100pixel should be same, but the width need to varie with respect to the image ratio.

And finally the image view should be in center of the view

How to achieve it

  • 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-13T22:13:46+00:00Added an answer on June 13, 2026 at 10:13 pm

    There are a couple of ways you can achieve this. The simplest is to set the scaling mode on the image view to Aspect Fill in Interface Builder, or

    imageView.contentMode = UIViewContentModeScaleAspectFit;
    

    The second way is to calculate the aspect ratio of the image and set the width. Something like:

    UIImage *myImage = [UIImage imageNamed:@"MyImage"];
    float aspectRatio = myImage.size.width / myImage.size.height;
    float viewWidth = 100 * aspectRatio;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my iPhone app I need to round an integer to the nearest multiple
I am making my first major iPhone app and need some advice in saving
I'm in the processes of internationalizing an iPhone app - I need to make
I am building an iPhone app that will need to display info primarily in
I want to make a iPhone app but I need to now how you
I'm currently creating an iPhone app and we need some testing with about 20~30
I need to integrate Foursquare to my iPhone app. I need to do the
On a iPhone app, I need to send a jpg by mail with a
I need to implement 'graphing paper' in an iPhone app. The user should be
I need to have a few buttons in my iPhone app (which may be

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.