Вопрос

Sounds easy enough but I can't seem to figure this one out or find any help for it.

This is the hierarchy I have at the moment:

Window
    Custom View (I want this to resize, with its children, to fit Window)
        Custom View (Contains buttons)
        NSBox (gets content set to the WebView below)
WebView

On applicationLoad, I invoke setContentView on the 'NSBox' to the WebView.

So I end up with an NSBox with a WebView inside it, within a custom view.

If I have an IBAction linked to a button, what do I need to do to get the outer Custom View to resize to fit the Window? Hopefully this would also resize the contents, including the NSBox and the WebView.

Is this possible?

Any help greatly appreciated.

Thanks in advance everyone!

EDIT: ATM i have the following code which makes one WebView larger and makes the other hidden, but it positions the view too high up in the window?

oldView.hidden = YES;
[newView setFrameSize:_window.frame.size];
Это было полезно?

Решение

Unless your old view was positioned at {0,0} in the coordinates of the window's contentView, it's going to be too high when you change its size to that of the window. Try this:

[newView setFrame:[_window.contentView frame]];

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top