• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to resize accessory view to match Open panel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to resize accessory view to match Open panel


  • Subject: Re: How to resize accessory view to match Open panel
  • From: Jonathan Taylor <email@hidden>
  • Date: Fri, 10 Jul 2015 12:21:35 +0100

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 <email@hidden> wrote:

> On Jul 9, 2015, at 7:05 AM, Jonathan Taylor <email@hidden> 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 (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


References: 
 >How to resize accessory view to match Open panel (From: Jonathan Taylor <email@hidden>)
 >Re: How to resize accessory view to match Open panel (From: Lee Ann Rucker <email@hidden>)
 >Re: How to resize accessory view to match Open panel (From: Jonathan Taylor <email@hidden>)
 >Re: How to resize accessory view to match Open panel (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Swift 2 throws from init()
  • Next by Date: PSA: floor(NSFoundationVersionNumber) doesn't work with Yosemite or later
  • Previous by thread: Re: How to resize accessory view to match Open panel
  • Next by thread: How can I make my application support splitview in El Capitan?
  • Index(es):
    • Date
    • Thread