Well, I think I have bumbled my way towards a working solution that seems to 
work (tested on OS 10.9), although this was largely through trial and error and 
so might not be the best way of doing things. Thankyou very much to everyone 
who offered help on and off list.

One indirect clue I found was here:
http://stackoverflow.com/questions/27374355/nssavepanel-crashes-on-yosemite
(I encountered the same issue if I set 
translatesAutoresizingMaskIntoConstraints=NO in the nib itself)

Another was the failure of my attempts to manually set my own constraints on my 
view, after adding it to the NSOpenPanel. As far as I can tell, the act of 
adding it causes NSOpenPanel to apply some fairly aggressive auto-constraints, 
and I didn’t manage to work out how I could override them. That might somewhat 
explain why my attempts to change things in my nib file weren’t having much 
effect - I suspect that NSOpenPanel is specifically overriding certain 
properties with ones it has chosen itself.

Anyway, long story short: AFTER adding the view as openPanel.accessoryView, I 
manually set the view rectangle to fill its parent view, and then I do:
        viewController.view.autoresizingMask = NSViewWidthSizable | 
NSViewHeightSizable;        // Must be done AFTER adding as accessory view
This seems to result in the behaviour I want (my view fills the available 
space, and scales as the window is resized). This works regardless of whether 
the nib itself is set to autolayout or not.

Hopefully that information might be of some use for posterity.

Cheers
Jonny



On 9 Jul 2015, at 16:18, Ken Thomases <k...@codeweavers.com> wrote:

> On Jul 9, 2015, at 7:05 AM, Jonathan Taylor <jonathan.tay...@glasgow.ac.uk> 
> wrote:
> 
>> I gave it a try, setting what I thought should be needed, but it doesn’t 
>> seem to be having the desired effect as yet. I have the nib file set to “Use 
>> autolayout”, and have included the code you quoted.
> 
> Even in a NIB set to use auto layout, top-level views have 
> translatesAutoresizingMaskIntoConstraints turned on.  So, you should turn it 
> off in the NIB on the Attributes inspector or in code after you've loaded it, 
> if the open panel is expected to be auto-layout-savvy.  (In general, 
> actually, one should leave it on and let the code which places the view into 
> a larger hierarchy decide whether to turn it off.  But maybe turning it off 
> will work for this case.  I don't know.)
> 
> 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

Reply via email to