Loading views into NSContainerView with swift

后端 未结 1 1239
有刺的猬
有刺的猬 2021-01-15 18:18

I have a storyboard setup with the main view having a bunch of buttons and a container view and I would like for a different view to be loaded into that container view each

相关标签:
1条回答
  • 2021-01-15 18:33

    "Container View defines a region within a view controller's view subgraph that can include a child view controller. Create an embed segue from the container view to the child view controller in the storyboard."

    You mentioned NSContainerView, so I assume you're trying to do this on macOS, not iOS. Here's a useful article and code project (for iOS 6, but I was able to set up switchable subviews in iOS 9 using this as a guide): http://sandmoose.com/post/35714028270/storyboards-with-custom-container-view-controllers

    The important bits are using the embed segue, then wiring the view controllers together through a combination of viewDidLoad and prepareForSegue, and then finally loading one of the switchable view controllers (say one for each of your buttons) from the storyboard, where they are not connected to anything else.

    0 讨论(0)
提交回复
热议问题