gpt4 book ai didi

iphone - 添加导航栏按钮的最佳位置?

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

我应该将创建 UIBarButtonItem 并将其分配给 self.navigationItem.rightBarButtonItem 的代码放在哪里?在 initWithNibNameviewDidLoad 中?

编辑:我应该澄清一下,我正在从 Interface Builder 加载 NIB。

最佳答案

viewDidLoad 是编程创建按钮的正确位置,无论您是否从 Interface Builder 加载 NIB。

来自UIViewController类,viewDidLoad方法文档

This method is called after the view controller has loaded its associated views into memory. This method is called regardless of whether the views were stored in a nib file or created programmatically in the loadView method. This method is most commonly used to perform additional initialization steps on views that are loaded from nib files.

关于iphone - 添加导航栏按钮的最佳位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7814052/

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