there is a window controller connected to the view controller
when the menu item click I want to show that window as modal
after that the window is show, but I found that the view controller not follow the window controller's appearance
also any window controller appearance is not working.. including content size, window title... etc
So what is the problem?
The view renders presentation of the model in a particular format. The controller responds to the user input and performs interactions on the data model objects. The controller receives the input, optionally validates it and then passes the input to the model.
Consider that you are presenting only the view controller and not any related window controller you define if you use presentAsModalWindow(_ viewController: NSViewController)
The viewController is made the delegate and contentViewController of the window while it is shown
You could make the window customisations in viewWillAppear of your custom view controller
override func viewWillAppear() {
let closeButton = view.window?.standardWindowButton(.closeButton)
closeButton?.isHidden = true
}
In viewDidLoad
the window property will be still nil.
If you want to present your window controller do something like this triggered my your menu item.
@IBAction func showMyWindowController(sender:NSMenuItem){
let storyboard = NSStoryboard(name: "Main", bundle: nil)
let windowController = storyboard.instantiateController(withIdentifier: "MyWindowController") as! NSWindowController
windowController.showWindow(self)
}
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With