When the user closes the main application window there is no menu item to re-open it, Xcode, MacOs app

Viewed 753

My MacOs app has been rejected. One of the point to solve is:

It would be appropriate for the app to implement a Window menu that lists the main window so it can be reopened, or provide similar functionality in another menu item. macOS Human Interface Guidelines state that "The menu bar [a]lways contains [a] Window menu".

I really do not understand what to do... This is the first time I am submitting a MacOs App...

This is my AppDelegate.swift file.

1 Answers

Please find below the solution that I share with you. Thanks Trojanfoe for pointing me in the good direction. I hope it will help MacOS beginners like me.

My app has a home page that you see at start up and stays on the screen as long as you do not interact. Once you interact you leave the home page and cannot come back to it because there is no button in the app that allows it or there is no Main Window menu item that allows it.

The Apple review Team rejected my app and said: « Specifically, we found that when the user closes the main application window there is no menu item to re-open it.
It would be appropriate for the app to implement a Window menu that lists the main window so it can be reopened or provide similar functionality in another menu item. macOS Human Interface Guidelines state that "The menu bar always contains a Window menu".

I then sick for help on Stackoverflow and also on the web and finally find out the below solution of adding a Window menu item that will display the home page if clicked.

Click on Main.storyboard to display the Main Menu

Click on the Window’s Menu item

Click on + to select a Menu Item and drag it into the Window’s Menu item

Rename item into “Home Page” on the above left and the right locations

Open the AppDelegate.swift file on the right side

CTRL + drag the “Home Page” item to the AppDelegate.swift file for IBAction creation

The IBAction is now ready to be filled-up

Tell the action to display the Home Page View (in my App it is ContentView())

Now if we start the app, we have a “Home Page” item in the Main menu Window and if we click on it, we go the ContentView() that is my app Home Page.

Code for the action:

@IBAction func DisplayHomePAge(_ sender: NSMenuItem) {
    window.contentView = NSHostingView(rootView: ContentView())
}
Related