gpt4 book ai didi

ios - 是否应该从 loadView 调用 [super loadView]?

转载 作者:可可西里 更新时间:2023-11-01 03:32:33 29 4
gpt4 key购买 nike

在 Matt Newburg 的 Programming iOS 4 中他说:

“To provide a UIViewController with a view manually, implement itsloadView method… You must NOT call super”.

在 Erica Sadun 的 iOS 5 Developer's Cookbook 中,她指出:

“The loadView method allows you to set up the screen and layout anysubviews… Make sure to call [super loadView] whenever you inheritfrom a specialized subclass such as UITableViewController orUITabBarController.”

至少对我来说,这是令人困惑的。

最佳答案

Apple 是真相的来源,他们说没有 super 电话。

If you override this method in order to create your views manually,you should do so and assign the root view of your hierarchy to theview property. (The views you create should be unique instances andshould not be shared with any other view controller object.) Yourcustom implementation of this method should not call super.

https://developer.apple.com/documentation/uikit/uiviewcontroller/1621454-loadview

[编辑]

散布在 UIViewController 类引用中的另一个重要说明:

The default loadView method attempts to load the view from the nibfile associated with the view controller (if any).

关于ios - 是否应该从 loadView 调用 [super loadView]?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9105450/

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