Question

I have a nib file, in which I have created an NSView.

This view has two states. If it is "Off," then only some items at the top are visible. If it is "On," then the entire view is visible (disclosure triangle thing).

Now, I currently have the display rect hardcoded (using static const). However, I want to be able to change the nib, and not have to go and tweak any magic numbers.

Simple enough. I simply get the frame property of some nib elements, and Bob's your uncle.

I need to get these dimensions before the view is displayed. It is instantiated, but has CGRectZero as the frame for everything until it's displayed.

Is there a "proper" way to extract the dimensions in code for nib items from a loaded (but not displayed) nib?

Was it helpful?

Solution

You need to look at the awakeFromNib method, which is called after the nib is loaded so that you can configure the view before it is displayed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top