How does one display a new view controller in the same Mac window?

后端 未结 3 1191
名媛妹妹
名媛妹妹 2020-12-14 01:39

I\'m fairly new to Mac development and am slightly confused by the new \"storyboard\" feature in Xcode 6. What I\'m trying to do is segue from one view controller to another

3条回答
  •  无人及你
    2020-12-14 01:56

    If you provide a custom segue (subclass of NSStoryboardSegue) you can get the result you are after. There are a few gotchas with this approach though:

    • the custom segue will use presentViewController:animator so you will need to provide an animator object
    • because the presented view is not backed by a separate Window object, you may need to provide it with a custom NSView just to catch out mouse events that you don't want to propagate to the underlying NSViewController's view
    • there's also a Swift-only glitch regarding the custom segue's identifier property you need to watch out for.

    As there doesn't seem to be much documentation about this I have made a small demo project with custom segue examples in Swift and Objective-C.

    enter image description here

    I also have provided some more detail in answer to this question.

提交回复
热议问题