1
votes

I created a new Cocoa Application which is using auto-layout. On the window, I added a NSView which nearly fills the window. Inside of this NSView, I placed a button in the upper left corner. When I run the application and resize the window to its smallest width and then resize the window to its largest width, the button will not draw correctly. If I turn off auto-layout and try the same procedure, the button will draw correctly.

When resizing the window, I only grab & drag the right hand side of the window.

I'm sure I am missing something obvious, but I am not certain what that might be.

I have a sample test project here: autolayout test

After resizing narrow and then back to wide quicklyAFter resizing partially narrow and then back to wide

1
You say it doesn't draw correctly. Would you post a screenshot of the problem? - paulmelnikow
Added. Do you not see the same problem? I have trivially reproduced this now on several machines. - ericg
What are the constraints on the view? - paulmelnikow
I literally just dragged two views into IB. The constraints are whatever IB decided should be the default constraints without any modifications by me. I would suggest downloading the project and taking a look at the xib or just creating your own test project and recreate the problem. However, you can grab some screen shots at ericgorr.net/cocoadev/autolayout01-01.png, ericgorr.net/cocoadev/autolayout01-02.png, & ericgorr.net/cocoadev/autolayout01-03.png - ericg
Thanks for posting the screenshots. Would you try setting a minimum size for the window of about 250x250? I think that should fix the problem you're seeing. Basically, the constraints in the second screenshot don't make sense when the window gets really small. - paulmelnikow

1 Answers

0
votes

I can also reproduce this. It appears to happen only to NSButtons (also NSTextFields, and probably many other NSView subclasses) that are aligned to the inner NSView's left edge; objects aligned to the inner NSView's right edge or horizontal center redraw appropriately.

I can fix it by creating an NSView subclass and replacing the inner NSView with an instance of the subclass. but I believe I shouldn't have to. Eric, I'd suggest filing a bug report as an Apple Developer: http://developer.apple.com/bugreporter/