How to full screen application with Mavericks API

I am currently developing an application in OS X and just trying to set the application to full screen. I did some research and found out that I need to call a function from the object sharedApplicationthat I placed in the method applicationDidFinishLaunching.

[[NSApplication sharedApplication] setPresentationOptions:NSApplicationPresentationFullScreen];

However, when I start the application, I get this message for me.

setPresentationOptions called with NSApplicationPresentationFullScreen when there is no visible fullscreen window; this call will be ignored.

I could not find a solution, can someone explain how I can resolve this statement? This is what I understood from the message, I can’t install my application in full screen mode, if my window is not in full screen mode, it does not make sense to me, because I will need to have a smaller window for me to maximize later. What's happening?

Update 1: The video link of the error is recreated here. Please watch this His 4 minutes in length.

+4
source share
1 answer

Ok, hopefully this is a helpful answer.

First, I'm going to discuss the difference in the development of the underlying application between iOS and Mac and continue to work with NSWindowController, and then try to explain why you caused unexpected behavior!

Differences between iOS and Mac

Nibs

, - Mac ( iOS), UIApplicationMain AppKit; NSApplicationMain; . iOS UIApplication UIApplicationDelegate , Mac NSApplication NSApplicationDelegate. , AppDelegate, NSApplication. Info.plist NSPrincipalClass, , NSApplication . , . Info.plist NSMainNibFile, , nib. :

  • : . , AppDelegate ( PREFIXAppDelegate). , nib , NSApplication.
  • : NSFontManager Mac. , UX .
  • : , . - , , .

? iOS, , , . , . , Mac , . , , ( ) mac ( - ). , Mac NSMainNibFile, nib!

"ya ya, , nibs, ew!" . , , , ! !

, , , NSPrincipalClass Info.plist . -init *, NSApplication . , ( , nib). , NSApplication ( POV ), ( ). , , , NSApplicationDidFinishLaunchingNotification ..

NSWindowController

(, , ). , NSWindowController, -showWindow:.

, NSWindowController, " nib" ( ). , NSWindowController , , ( , - , !)! , " " , .

Apple docs " , , , ".

, ? ( , ). Anywho, , , (, -init) /.

?

, MainMenu.nib, . , . - . nib, , /​​/ ( , , , ).

-showWindow:, [windowController.window toggleFullscreen:nil]. , ( ).

, , (IMO great looking). Mac-, , :

  • . iOS, , . , NSView backgroundColor, , , , -drawRect: ( , //, ).
  • ? NSViews Mac CALayer . , -setWantsLayer:YES NSView, . YES - (BOOL)wantsLayer , . NSView , - (BOOL)wantsUpdateLayer, - (void)updateLayer - (void)drawrect:(NSRect)r .
  • . , iOS. , UIKit - . , AppKit Mac , -, . , , , , , , . , , !

EDIT: . Mac this!

* , 10.7/8, 10.9

: ( , - ), , . , !

+4

Source: https://habr.com/ru/post/1539700/


All Articles