Setting subview's width equal to window width on launch
I'm struggling getting a subview (which is acting as a custom toolbar [I need a NSView
rather than an NSToolbar
]) centred within an INAppStoreWindow
..
The subview is being added correctly, and stretches correctly only if the window is exactly the same width as the custom view that I've 开发者_如何学编程created in IB.
If the window opens wider than the custom view, it does not stretch properly. The window seems to open in exactly the same state as I left it (in Lion), which therefore means I have to set the width of the custom view to the restored window width on launch.
It's also important that the buttons etc I have placed in the centre of the view in the nib remain centred...
How do I do this?
Edit: to make this clear, how do I get a restored window's width? I have set it to 480 in the nib file but if I resize the window, quit then restart the app, window.frame.size.width
still returns 480, not the width I quit with..
Many thanks
I take it you are not creating the NSWindow
in interface builder, you can override -[NSView viewDidMoveToWindow]
or -[NSView viewWillMoveToWindow]
to set the width, there are also viewDidMoveToView
equivalents which may make more sense since you view gets added to the NSWindows
contentView, there is also awakeFRomNib
which you can override which may b he better choice if you only have to worry about the issue once when you vie loads from the Nib file.
精彩评论