viewDidLoad in NSViewController?

前端 未结 6 520
走了就别回头了
走了就别回头了 2020-12-01 02:15

On the iPhone I use UIViewController\'s viewDidLoad to run code to set up the view.

How can I do that with NSViewController?

6条回答
  •  猫巷女王i
    2020-12-01 02:26

    As of OSX 10.10 (Yosemite), there is now a -viewDidLoad, -viewWillAppear, -viewDidAppear, -viewWillDisappear in NSViewController. See WWDC 2014 - Storyboards and Controllers on OS X session for more info, to find out when each of them gets called, etc.

    Here's the relevant bit from the 10.10 header docs about -viewDidLoad:

    Called after the view has been loaded. For view controllers created in code, this is after -loadView. For view controllers unarchived from a nib, this is after the view is set. Default does nothing.

    - (void)viewDidLoad NS_AVAILABLE_MAC(10_10);
    

提交回复
热议问题