Re: How to reposition subviews without Auto Layout
Re: How to reposition subviews without Auto Layout
- Subject: Re: How to reposition subviews without Auto Layout
- From: じょいすじょん via Cocoa-dev <email@hidden>
- Date: Sun, 18 Oct 2020 00:00:58 +0900
> On Oct 17, 2020, at 9:57 PM, Andreas Falkenhahn via Cocoa-dev
> <email@hidden> wrote:
>
> Hi,
>
> I have an NSView that I set as the content view of my NSWindow. The NSView
> has three subviews. Where should I reposition and resize those three subviews
> when the NSWindow size changes?
>
> I see that NSView has a "layout" method that can be overridden but AFAIU this
> is only to be used for Auto Layout. I don't want to use Auto Layout because
> my whole layout is very simplistic and just involves those three subviews
> which I can easily position and size manually. I just need to know where to
> put the code that sets their new position and size... anyone?
>
> --
> Best regards,
> Andreas Falkenhahn mailto:email@hidden
> <mailto:email@hidden>
I'm not sure why you would avoid Auto Layout at this point. It's generally
easier than the alternative.
Either way, Auto Layout is really the default these days and things more or
less get to live in and Auto Layout world.
That said, what have you tried?
This method might do the trick, but there might be more involved than you
expect.
You might want to look at the methods in NSWindowDelegate as well as the
NSNotificationNames of NSNotifications you can register for in NSWindow.h
There are a variety of ones regarding resize and zoom.
You might also want to consider ones that involve the view being occluded or
moving to a display with a different resolution, as well as different
accessibility and appearance changes.
Then you have internationalization.
One of the big benefits of Auto Layout is getting fairly free support for
left-to-right and right-to-left language layouts, and another is views that can
automatically (mostly) expand and contract to support variations in string
lengths by localization.
Please consider all of these points and how they might affect your layouts.
The rabbit hole is deep sometimes.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden