Re: Triggering a segue from code
Re: Triggering a segue from code
- Subject: Re: Triggering a segue from code
- From: Quincey Morris <email@hidden>
- Date: Sun, 18 Sep 2016 13:32:54 -0700
- Feedback-id: 167118m:167118agrif8a:167118sTzTUUHNlm:SMTPCORP
On Sep 18, 2016, at 12:22 , email@hidden wrote:
>
> While I do see the log message 'How do I..', my utility panel is not shown.
>
> How can I get this work?
Most of the problem is that storyboards and segues for the Mac are inadequately documented. This is exacerbated by the fact that understanding the behavior “by analogy with iOS” breaks down when windows are involved, since there’s no such thing (AFAIK) as a segue between windows on iOS.
By trial and error, I discovered that the problem in your sample project is that a “show” segue from a view controller does not open a new window. This halfway makes sense, although the fact that it does nothing and produces no exception or log message is pretty unhelpful. (Bug report!)
To get the button to display the panel, you need to have the window controller perform the segue. That means you’ll need a custom window controller subclass for the main window, and you can just move the action method into the window controller. (Hook the button up to First Responder instead of the view controller, too.)
Alternatively, go back to using a segue from the button to open the panel, which IIRC was working in an earlier version of this test project. (You posted that it wasn’t working, but when I went to look at your project you’d already fixed the problem in your project that was preventing it from working. IIRC.)
To do all the combinations of hiding and showing a singleton panel, you’ll probably want another custom window controller subclass for the panel itself. Not every window/window controller operation seems to be mapped into storyboard semantics, so you should expect that there are things that still need to be done “the old way”.
_______________________________________________
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