本文介绍了NSViewController 中的 viewDidLoad?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 iPhone 上,我使用 UIViewControllerviewDidLoad 运行代码来设置视图.

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

如何使用 NSViewController 做到这一点?

How can I do that with NSViewController?

我试过 loadView 但它不起作用...

I've tried loadView but it doesn't work...

推荐答案

从 OS X 10.10 开始,viewDidLoadNSViewController 上可用和支持.

As of OS X 10.10, viewDidLoad is available and supported on NSViewController.

在此之前,您必须在 Snow Leopards 的 发行说明:

Prior to that, you had to go by this nugget in Snow Leopards' release notes:

给正在寻找 NSViewController 中 -viewWillLoad 和 -viewDidLoad 方法的人的建议

尽管 NSWindowController 有 -windowWillLoad 和 -windowDidLoad 方法让你覆盖 Mac OS 10.5 中引入的 NSViewController 类,但没有相应的 -viewWillLoad 和 -viewDidLoad 方法.您可以覆盖 -[NSViewController loadView] 以自定义在视图控制器完成笔尖加载之前或之后立即发生的事情.

Even though NSWindowController has -windowWillLoad and -windowDidLoad methods for you to override the NSViewController class introduced in Mac OS 10.5 does not have corresponding -viewWillLoad and -viewDidLoad methods. You can override -[NSViewController loadView] to customize what happens immediately before or immediately after nib loading done by a view controller.

这篇关于NSViewController 中的 viewDidLoad?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 13:30