how to handle applicationShouldHandleReopen in a Non-Document based Storyboard Application

后端 未结 2 2002
迷失自我
迷失自我 2021-02-03 11:14

The best I have been able to figure out is:

func applicationShouldHandleReopen(sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {

    if !flag{
          


        
2条回答
  •  面向向阳花
    2021-02-03 11:46

    In case you are looking for a cocoa-based solution for non-document apps. This is the equivalent of Adam's second solution.

    - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
    {
       if(!flag)
       {
           for(id const window in theApplication.windows)
           {
               [window makeKeyAndOrderFront:self];
           }
       }
       return YES;
    }
    

提交回复
热议问题