1
votes

I'm writing a Cocoa application which should work in fullscreen mode. I would like to detect the user setting the application window to fullscreen mode. In Xcode,

  1. in the Attributes Inspector, Full Screen value is "Primary Window"
  2. in the File Inspector, Use Auto Layout is unchecked
  3. the view of the main window has Autoresizes Subviews unchecked

I'm making the AppDelegate an NSWindowDelegate like this in AppDelegate.h

@interface AppDelegate : NSObject <NSApplicationDelegate, NSWindowDelegate>

and have a method like this in AppDelegate.m

-(void) windowDidEnterFullScreen:(NSNotification *)notification
{
   vuMain.view.frame = NSMakeRect(0, 0, window.frame.size.width, 
   window.frame.size.height);
   NSLog(@"AppDelegate - windowDidEnterFullScreen");
}

But this method is not getting called as there is no NSLog output. A watch set in the method does not get reached.

What am I doing wrong? What am I missing?

Please help! I'm rather new to Cocoa and am struggling for one full day with this. Thanks

1
Have you actually made the AppDelegate the window's delegate? You either have to connect the window's delegate outlet to the AppDelegate in the NIB, or you need to set the window's delegate property programmatically. - Ken Thomases
Thanks Ken! That did the trick. - Shaan van Inde

1 Answers

1
votes

You need to actually make the AppDelegate the window's delegate. You either have to connect the window's delegate outlet to the AppDelegate in the NIB, or you need to set the window's delegate property programmatically.