gpt4 book ai didi

iphone - 并加载 NIB/XIB 文件?

转载 作者:太空狗 更新时间:2023-10-30 03:48:48 38 4
gpt4 key购买 nike

我有点好奇,我有一个 View Controller 类和一个 NIB/XIB(都命名为“MapViewController”)如果我执行以下操作,它会加载具有匹配名称的 NIB。

-(id)init {
self = [super initWithNibName:@"MapViewController" bundle:nil];
if(self) {
do things ...
}
return self;
}

另一方面,如果我只指定 [super init],Xcode 是否只查找与 Controller 名称匹配的 NIB,这是如何工作的?

-(id)init {
self = [super init];
if(self) {
do things ...
}
return self;
}

干杯加里。

最佳答案

来自文档:

If you specify nil for the nibName parameter and do not override the loadView method in your custom subclass, the default view controller behavior is to look for a nib file whose name (without the .nib extension) matches the name of your view controller class. If it finds one, the class name becomes the value of the nibName property, which results in the corresponding nib file being associated with this view controller.

关于iphone - 并加载 NIB/XIB 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2951652/

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