English 中文(简体)
在创建自定义视图控制器时, 为什么我们不应该在 MaxView 中调用 [超载视图]?
原标题:Why should not we call [super loadview] in loadView when creating a custom View controller?

苹果开发商"http:// developer.apple.com/library/ios/#festated articles/View unloadingand Unloading/View Loadingand Unloading.html#/apple_ref/doc/uid/TP400007457-CH10-SW37" rel="nofollow" > reference 。它们的意思是“这样做会引发默认的浏览装入行为?

When overriding the loadView method to create your views programmatically, you should not call super. Doing so initiates the default view-loading behavior and usually just wastes CPU cycles. Your own implementation of the loadView method should do all the work that is needed to create a root view and subviews for your view controller. For more information on the view loading process, see “Understanding How Views Are Loaded and Unloaded.”

问题回答

“ 默认行为” 正在装入相同名称的 XIB 文件, 连接属性等 。 如果没有匹配的 XIB 文件, 正如文件所说, 它会只是浪费 CPU 循环 。

最终,不知道苹果是如何执行这个框架的,我们“他们”知道文件中所有建议背后的理由。但这并不意味着你应该忽略这些建议。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签