On Dec 20, 2014, at 16:10 , Ken Thomases <[email protected]> wrote: > > You've shown the constraints for the size of the subview.
There was an exchange in this thread that I just realized wasn’t posted to the list. I *think* this was accidental on the OP’s part, so I’ll copy the messages here, since they are (IMO) crucial to the issue: > On Dec 20, 2014, at 13:50 , H Miersch <[email protected]> wrote: > > On 20. Dec 2014, at 21:26, Quincey Morris > <[email protected] > <mailto:[email protected]>> wrote: > >> I’d be more concerned about timing: Did you add constraints before or after >> layout had occurred, and if after do you need to trigger a re-layout? > > not sure when layout occurs, but as i say below, that method is called from > drawrect. and i added several setneedslayout calls after the creation of > those constraints. didn't help. > >> Also, your ‘setFrameSize’ method suggests you *might* still be setting the >> view frame somewhere. You don’t want to do that under auto-layout. > > drawrect calls the method that determines the required size of the view > that method then finds out what size the view should be and sets that size > using setframesize. BTW, that is the only place in that class that i call any > method with set frame in its name. > then the method sets the size constraints to the same size. > > so are you saying i should remove that setframesize and rely on the > constraints? > >> If you’re using Xcode 6, you also have debugging assistance in the view >> hierarchy display. (It’s a button down near the continue/step controls in >> the debugger pane.) > > no, it's Xcode 5.1.1 > >> You also have -[NSWindow visualizeConstraints:] to help figure out what’s >> going on. > > i'll see where that takes me... and then: > On Dec 20, 2014, at 14:33 , Quincey Morris > <[email protected]> wrote: > > On Dec 20, 2014, at 13:50 , H Miersch <[email protected] > <mailto:[email protected]>> wrote: >> >> not sure when layout occurs, but as i say below, that method is called from >> drawrect > > From -[NSView drawRect:]?? You most definitely should not be computing the > view size there, let alone resizing the view or setting constraints. > > I suppose it would be fine to compute a *future* view size there, if that’s > where the calculation logic is, but it’s far too late make the view that size > *this* time. IAC, it would be better to factor out the calculation and do it > somewhere that’s no so far too late. > >> drawrect calls the method that determines the required size of the view >> that method then finds out what size the view should be and sets that size >> using setframesize. BTW, that is the only place in that class that i call >> any method with set frame in its name. > > If this is -[NSView setFrameSize:] (as opposed to a custom method that merely > captures the size in some custom instance variables), then it’s still setting > the frame, which you must not do when using auto-layout. The whole purpose of > auto-layout is to set the frame for you. _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
