Objective-c – Minimum window size of a Mac OS X application

cocoamacosnswindowobjective cxcode

Two questions here.

First question, In my Mac OS X application the window has resizing enabled. My window contents are on a 500×500 window size. Problem is that user can resize it so some of the contents cutts off. What I need to do so user can only resize to a minimum size (In my case 500×500)?

Second question, When I close my Mac application (by clicking red cross button on window top) the app icon stays in the dock at the bottom. When user click on it again it does not fire up the application unless user quit the application all togeter and relaunches it again. What settings do I need so user can close and relaunch it by clicking dock icon?

Thanks

Best Answer

Use -[NSWindow setMinSize:] to set the minimum size programmatically, but you can also set the minimum size inside Interface Builder (look at the tab with the sizes).

To make the application quit when the window is closed, you need to add this to your app delegate:

- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication
{
    return YES;
}
Related Topic