Everyone knows that the full screen needs to call methods: [Window Togglefullscreen: Sender];
But sometimes it doesn’t take effect, when you need to set up WINDOW’s Behavior when you initialize, as follows
[Window SetCollectionBehavior: nswindowcolctionbehaviorfullscreenprimary];
Then call: [Window Togglefullscreen: Sender] can take effect.
NSWINDELEGATE in AppDelegate
There is a need to listen to two methods, as a change in the interior scene, or the change in layout.
– (void) Windowwillenterfullscreen: (nsnotification *) Notification;
– (void) WINDOWDIDENTERFULLSCREEN: (nsnotification *) Notification;
Code level, do not use InterfaceBuilder
Full Screen has two modes, which are NSWindowCollectionBehaviorfullscreenprimary and NSWindowCollectionBehaviorfullscreenauxiliary, most of which only need NSWINDOWCOLLECTIONBEHAVIORFULLSCREENPRIMARY.
After setting NSWINDOWCOLLECTIONBEHAVIORFULLSCREENPRIMARY, a full-screen button is displayed in the right window on the upper right corner of Window, the user can switch the program to full screen through this button.