简体   繁体   中英

Opening the login window on clicking on the application icon from dock

After closing the application, When i click on the application's icon on dock, i need it to open the login window. I have used,

  -(BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag
  {
  return YES;
  }

 - (BOOL)windowShouldClose:(id)sender {
   [[NSApplication sharedApplication] hide:self];
   // [NSBundle loadNibNamed:@"MainMenu" owner:self];
   return YES;
  }

But when i click on the icon at the dock, the login window is not getting loaded. Any ideas? Thanks.

To close the application when your Login Window is closed (assuming it's the only one opened in your application) you can implement applicationShouldTerminateAfterLastWindowClosed: in your application's delegate:

- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)app 
{
    return YES;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM