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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:06:47+00:00 2026-05-11T22:06:47+00:00

When writing Cocoa apps, I do the majority of the user interface layout programmatically.

  • 0

When writing Cocoa apps, I do the majority of the user interface layout programmatically. For example:

NSRect popUpFrame = NSMakeRect(10, 10, 100, kDefaultPopUpButtonHeight);
NSPopUpButton * popUp = [[NSPopUpButton alloc] initWithFrame:popUpFrame];
//...

My question is about that kDefaultPopUpButtonHeight constant. I currently maintain a source file full of such constants, and I fill in the proper sizes manually. I am able to determine the correct sizes by dropping a new control into a blank view in Interface Builder and then checking its properties to see what size IB gives it.

There must be a better way. Is it possible to access these values at runtime? Ideally, I would expect every NSControl to have a class method something like: +(NSSize)defaultSize, or, for controls like NSButton that have different default sizes depending on the particular button style used, something like +(NSSize)defaultSizeForButtonStyle:(NSButtonStyle)buttonStyle.

Apple’s Human Interface Guidelines has information about control layout and the spacing between controls, but it doesn’t say anything about the proper sizes for individual controls.

  • 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-05-11T22:06:47+00:00Added an answer on May 11, 2026 at 10:06 pm

    I agree with Peter, and would recomend that you use Interface Builder. But if that isn’t appropriate in your situation, here’s one way to find the best size for most controls:

    NSSize idealSize = [[control cell] cellSize];
    

    If you need more control over the sizing, you can use the -[NSCell cellSizeForBounds:] method.

    Also, cellSize really gives you the minimum size for a control, not necessarily the best size. For example, for a Cocoa aqua style push button with the text “OK”, it would return a width that more narrow than the HIG would recommend. For your purposes, it sounds like you’re only interested in the fixed hight portion of the size. -[NSCell cellSize] should work great.

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

Sidebar

Ask A Question

Stats

  • Questions 226k
  • Answers 226k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to use AND to combine your criteria, not… May 13, 2026 at 1:13 am
  • Editorial Team
    Editorial Team added an answer This is as expected, since the Q estimate isn't the… May 13, 2026 at 1:13 am
  • Editorial Team
    Editorial Team added an answer If I understand correctly, you are referring to the feature… May 13, 2026 at 1:13 am

Related Questions

I'm writing a standard Cocoa application, and I've just started implementing AppleScript support for
When writing Cocoa and implementing a class method that accepts a delegate and one
When writing an application for MacOSX, using Cocoa/Objective-C, I'd like to be able to
Possible Duplicate: What are best practices that you use when writing Objective-C and Cocoa?

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.