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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:11:26+00:00 2026-06-14T17:11:26+00:00

On a program I am currently working on, I would like to lock the

  • 0

On a program I am currently working on, I would like to lock the aspect ratio of the main window to make sure some visual elements stay proportionate.

I have managed to get this working by doing the following in the AppDelegate class:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 

    [window setAspectRatio:NSMakeSize(1.48, 1.0)];

}

Whenever the user drags the window, the aspect ratio is locked as I would expect, but there is one issue. I have specified a window size in IB of 592×400, which does conform to the aspect ratio, but when I first try and resize the window while the application is running the window sort of quickly snaps to a new ratio. I am guessing that setAspectRatio: could be taking into the bar at the top of the window, and therefore messing up the calculation.

Does anybody know a decent workaround to this problem, or any alternative approach?

Also, is there an alternative way of resizing a window programatically that will respect the aspect ratio set by setAspectRatio?

Before, when changing the size programatically I have been using:

[window setContentSize:NSMakeSize(592, 400)];

Which I have tested to confirm that it ignores the specified aspect ratio, as would be expected!

Thanks!

  • 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-14T17:11:28+00:00Added an answer on June 14, 2026 at 5:11 pm

    The size in IB is the content size – it doesn’t include the 22 points for the titlebar (assuming a standard titlebar). What you want is to use setContentAspectRatio: instead.

    As for programmatic resizing, there’s no API for that. You should just decide which dimension is your reference and multiply or divide by the content aspect ratio appropriately to get the other, then setContentSize: as before.

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

Sidebar

Related Questions

I'm currently working on a small project and would like some help on it.
I'm currently working on a .NET Cybercafe management program and would like to calculate
When I start debugging the project we are currently working on, the program window
I am currently working on an application involving mapkit. I would like to add
I am currently working in Python and my program looks like this: function(1) function(2)
I have a program written in python, and I would like to make it
I am currently working on a program that utilizes RSSI to determine location based
I'm currently working on a C++ program in Windows XP that processes large sets
I'm currently working on a Program, that presses buttons for me. I'm working on
I'm currently working on a C# program that creates a List, of object Task,

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.