Re: layout method not getting called on Content View
Re: layout method not getting called on Content View
- Subject: Re: layout method not getting called on Content View
- From: Dave <email@hidden>
- Date: Thu, 16 Apr 2015 20:21:41 +0100
> On 16 Apr 2015, at 17:49, Quincey Morris <email@hidden> wrote:
>
> On Apr 16, 2015, at 08:41 , Dave <email@hidden <mailto:email@hidden>> wrote:
>>
>> Any advice on how to quickly achieve this would greatly appreciated, but it if means spending days reading documentation and experimenting just to set the frame of a view, then I may as well forget including this part in the demo and work on improving other parts of the application.
>
> The difficulty is that you’ve never actually said what the problem was with *not* using autolayout. You wrote:
It’s in the Title - “layout doesn’t get called" and I’m not sure where in the process to set the Frame, because if I do it just after the NIB is loaded it doesn’t seem to have any effect.
>> On Apr 15, 2015, at 11:47 , Dave <email@hidden <mailto:email@hidden>> wrote:
>>
>>> I have a WindowController/Window Combo contained in a NIB. Auto Layout is turned off and I want to alter to positions and/or sizes of views inside the ContentView. I thought the obvious place to do this was layout, but it never seems to get called?
>
>
> Assuming that the subviews of the content view are already in the view hierarchy (they were there in the nib, or you just added them programmatically), and autolayout is turned off for the content view, then the way to set the size and position of the subviews is to call ‘setFrame:’ on each one. That’s the way it was done before autolayout existed, and it should still work just fine when autolayout is not turned on.
>
> The ‘layout’ method *isn’t* the obvious or correct place to do this, because it’s API that belongs specifically to the autolayout ecosystem.
On iOS, there is a method called “layoutSubviews” that I’ve used to do this sort of thing in the past, so it was deemed the correct place to do this in iOS, I assumed it would be the same or similar for Mac.
>
> Did you try just setting the frames of your subviews?
Ok, so it *should* work ok with Auto Layout turned off and I should be able to do a setFrame whenever I want to and it should change the view position and size in the window?
If that is true, then maybe there is another problem and I’ll try to debug my code. It’s just when I asked everyone told me to use Auto Layout and didn’t confirm or deny if it *should* work ok with AL turned off, so I was beginning to think that it couldn’t be used any more.
> Did you try just setting the frames of your subviews?
Yes and it didn’t seem to have any effect, now I know it should be possible, I will dig deeper and see if I can figure out what is going wrong. The code in that area is a best messed up by all the stuff I’ve been trying out. I will straighten it out and try again.
Thanks a lot
Dave
_______________________________________________
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