Re: view problems
On Dec 20, 2014, at 12:08 , H Miersch hmier...@me.com wrote: if I DO call [self setTranslatesAutoresizingMaskIntoConstraints:NO]; on the subview, the window and its view behave normally, but the subview doesn't appear, its drawrect method is not called, nothing. so what am i doing wrong? It sure sounds like the custom view is having its size forced to zero because it has no size (or other) constraints that keep this from happening. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: view problems
On 20. Dec 2014, at 20:39, Quincey Morris quinceymor...@rivergatesoftware.com wrote: On Dec 20, 2014, at 12:08 , H Miersch hmier...@me.com wrote: if I DO call [self setTranslatesAutoresizingMaskIntoConstraints:NO]; on the subview, the window and its view behave normally, but the subview doesn't appear, its drawrect method is not called, nothing. so what am i doing wrong? It sure sounds like the custom view is having its size forced to zero because it has no size (or other) constraints that keep this from happening. hm, i hadn't thought of that. i'll try it out and let you know. signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: view problems
On 20. Dec 2014, at 20:39, Quincey Morris quinceymor...@rivergatesoftware.com wrote: On Dec 20, 2014, at 12:08 , H Miersch hmier...@me.com wrote: if I DO call [self setTranslatesAutoresizingMaskIntoConstraints:NO]; on the subview, the window and its view behave normally, but the subview doesn't appear, its drawrect method is not called, nothing. so what am i doing wrong? It sure sounds like the custom view is having its size forced to zero because it has no size (or other) constraints that keep this from happening. it looks like that didn't help. maybe i've made a mistake with the size constraints, or maybe there's something else wrong. i have a method that calculates the required height for the subview. here's the code i added to that method: [self setFrameSize:NSMakeSize(width, height)]; if (heightConstraint) { [self removeConstraint:heightConstraint]; heightConstraint = nil; } if (widthConstraint) { [self removeConstraint:widthConstraint]; widthConstraint = nil; } heightConstraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:height]; [self addConstraint:heightConstraint]; widthConstraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:width]; [self addConstraint:widthConstraint]; did i screw up? wouldn't surprise me, since this is my first project where i use constraints in code… come to think of it, should i add the constraints to the superview instead of self? gonna try that... signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: view problems
On Dec 20, 2014, at 13:09 , H Miersch hmier...@me.com wrote: should i add the constraints to the superview instead of self? The height and width constraints should be on the view itself. 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? Also, your ‘setFrameSize’ method suggests you *might* still be setting the view frame somewhere. You don’t want to do that under auto-layout. 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.) You also have -[NSWindow visualizeConstraints:] to help figure out what’s going on. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: view problems
On Dec 20, 2014, at 2:08 PM, H Miersch hmier...@me.com wrote: i have a window with a custom view in it. I add another view in code and then i add a couple of constraints to centre the new view in its superview. so far so good. if i DON'T call [self setTranslatesAutoresizingMaskIntoConstraints:NO]; on my subview, it appears, but the superview (and wit it the window) is reduced in size to the size of the subview, and i can't make the window bigger using the mouse. You've shown the constraints for the size of the subview. What are the constraints for centering it in its superview? Is the superview the window's contentView? If not, what are the constraints on the superview relative to _its_ superview? Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: view problems
On Dec 20, 2014, at 16:10 , Ken Thomases k...@codeweavers.com 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 hmier...@me.com wrote: On 20. Dec 2014, at 21:26, Quincey Morris quinceymor...@rivergatesoftware.com mailto:quinceymor...@rivergatesoftware.com 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 quinceymor...@rivergatesoftware.com wrote: On Dec 20, 2014, at 13:50 , H Miersch hmier...@me.com mailto:hmier...@me.com 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 (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: view problems
On 20. Dec 2014, at 22:33, Quincey Morris quinceymor...@rivergatesoftware.com wrote: On Dec 20, 2014, at 13:50 , H Miersch hmier...@me.com 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. ok, i've taken that method call out of drawrect: and instead i call the method every time one of the parameters changes. and now it works. thanks. signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com