gpt4 book ai didi

ios - 从 NibFile 加载 ViewController 时的自定义初始化程序

转载 作者:行者123 更新时间:2023-11-28 23:14:26 25 4
gpt4 key购买 nike

我在包含两个自定义 UIViewController 的 xib 文件中有一个 UISplitViewController。我将大部分初始化代码放在 viewDidLoad: 方法中,但我认为它不应该放在那里。

我可以覆盖什么方法以便在 xib 膨胀时运行我的代码?

提前致谢,如果您需要任何说明,请告诉我。

最佳答案

使用- (void)awakeFromNib .另一个选项是 -(id)initWithCoder:但我会推荐 awakeFromNib。

An awakeFromNib message is sent to each object loaded from the archive, but only if it can respond to the message, and only after all the objects in the archive have been loaded and initialized. When an object receives an awakeFromNib message, it is guaranteed to have all its outlet instance variables set.

关于ios - 从 NibFile 加载 ViewController 时的自定义初始化程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7026401/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com