NSSplitViewController based application almost never launches with the correct size

后端 未结 2 1393
自闭症患者
自闭症患者 2021-02-09 02:33

I have this app that uses a NSSplitViewController as the root and has a NSTabViewController connected as its detailViewController.

This app is

2条回答
  •  遥遥无期
    2021-02-09 02:59

    For reference, the same problem occurs if the window content segue points to an NSTabViewController scene. New windows open with a size of 500x500.

    I solved it by placing a plain view controller with a container view between my window and my main tab view controller. The window will then use the size of the container view as initial size.

    Here is what I did in detail:

    1. Added a new view controller scene to the storyboard
    2. Made that view the size I want my window to use initially
    3. Added a container view to the new view controller scene & added 4 constraints to have the container cover the view completely
    4. Connected the window's content segue to the new view controller
    5. Finally connect the container view to my actual tab view controller scene

    Before:

    [Window Controller Scene] → [Tab View Controller]
    

    After:

    [Window Controller Scene] → [View Controller Scene] → [Tab View Controller]
                                 (with Container View)
    

提交回复
热议问题