Re: More Layout Questions


Dave
 

Hi,

I’m confused then! The “layout” method has been around a lot longer than Auto Layout and it worked in conjunction with the Auto-Resizing options (defined in the Size Pane in IB). I assumed that in order to customise my layout I would override “layout” as done in the past, is this not the case?

You seem to be saying that If I want to layout my views myself, I don’t override the layout method or use setNeedsLayout? 

I could change the name of the method from “layout" to (say) “layoutView” for instance and instead of calling “setNeedsLayout” call “layoutView” on the subviews. However, at the moment when the window is resized, it initially calls “layout” in the WindowTracker view, do I still override this and “layoutView” on its subviews?

The only other way of handling I can think of is to override setFrame and do the layout there, does that sound like a better approach?

I’m just trying to find a decent way of laying out my views that’s fits into the way Cocoa works these days…..

Any advice or suggestions greatly appreciated.

All the Best
Dave


On 21 Sep 2018, at 17:28, Quincey Morris <quinceymorris@...> wrote:

On Sep 21, 2018, at 08:07 , Dave <dave@...> wrote:

I’m not sure what you mean, my storyboard file has Auto Layout DISABLED and there are no constraints anywhere in the project. Also, all the old-type layout options are off in the Size Panel in IB.

I mean that if you have disabled auto-layout, then you shouldn’t be trying to use auto-layout. Implementing the “layout” method comes under the heading of “trying to use auto-layout”, as the documentation says.

It may be possible that “layout” gets called anyway (it would have no effect unless you overrode it to do something), but the behavior isn’t documented in that case. You can’t rely on it to behave in any meaningful way.


Join cocoa@apple-dev.groups.io to automatically receive all group messages.