NSViewController disable resize when presented as Sheet?

user1001506 picture user1001506 · Nov 4, 2015 · Viewed 7k times · Source

So I am presenting an NSViewController as a sheet of a window that has resize disabled.

The view controller that is presented as a sheet can still be resized.

How do I disable resizing of a NSViewController?

Answer

balazs630 picture balazs630 · Feb 17, 2017

Swift 4:

override func viewDidAppear() {
   // any additional code
   view.window!.styleMask.remove(.resizable)
}

By the way you can do this without writing code, here is how:

  • Drag a Window Controller element to the Storyboard from the Object Library.
  • Connect the Window Controller to the specific View Controller which you want to disable resize.
  • On the Window Controller's Attributes uncheck Resize option.

disable resize window xcode