Search code examples
macoscocoamouseeventnsviewnsviewcontroller

macOS, changing the size of a view controller by dragging


The user clicks a button and I present a new viewController as show.

Inside that VC there is a AVPlayerView, the same size as the VC.

The app itself can change size if the user drags any of its corners but the VC displaying the movie cannot.

Why things like that that should work by default, don't work as expected? What can be done to make this work?

Example:

This is the main app.

enter image description here

I can drag its corners and make it bigger or small. I can click on the green semaphore and make it full screen and it works fine.

enter image description here

When I press the Help icon, this "window" appears. It is a viewController that was added the story board.

This cannot be scaled. It "appears" to be a window, because it contains a semaphore. I cannot scale this but I can make it full screen by the green semaphore.


Note: I have added the view to a WindowController and now when the user presses the Help button this window controller is launched and the video appears. No change. Video cannot be scaled.


Solution

  • Found the problem.

    1. I had to add a window controller controlling that View Controller.

    View controller was not resizing even after #1.

    Then I found that I could not have

    self.preferredContentSize = CGSize(width: 940,height: 504)
    

    inside awakeFromNib.

    Now it works perfectly.