Last week I spent a good amount of time fiddling around with the following problem. I solved it but since I couldn't find an answer here and I want to share my solution for anybody who runs into this.
Problem: My application runs in the background (menubar) and its main NSWindow
contains all the preferences of my application. You close the NSWindow
by clicking the close button in the top-left. After closing the NSWindow
and reopening it, all the NSControl
s were not visually responding. The actions worked accordingly, but they where not updating.
I tried the following:
- Unchecking "Release on close" in IB for
NSWindow
- Reloading
NSWindow
from NIB - Strong references for all
NSControl
s - Calling "Become first responder" on
NSControl
s - Reloading all the parenting
NSView
s - Implementing all the delegates hooking up each
NSControl
(Worked forNSControl
, but was way too much work to use it for each and every one) - Disabling and then reenabling the
NSControl
s
I'll post my solution below for the records.
My solution to this problem was to subclass
NSWindow
and overwrite the following methods:Now the
NSWindow
is hidden / ordered out and you just have to order it back in when displaying it.