【问题标题】:Replace xib file with Main.storyboard file in App delegate class用 App 委托类中的 Main.storyboard 文件替换 xib 文件
【发布时间】:2013-06-21 03:14:22
【问题描述】:

目前项目正在使用 App 委托类中的 MainWindow.xib 作为主 nib 文件。它在 main.m 文件中有此代码

int main(int argc, char *argv[]) {

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}

我想用 Mainstoryboard 替换它。我在 info.plist 文件中将其更改为 Mainstoryboard 文件基本名称,但它显示错误 没有设置应用程序委托。必须指定应用委托类才能使用主情节提要文件。

为了使用 Mainstoryboard 文件,我应该在 App 委托类中进行哪些编码。

谢谢

【问题讨论】:

  • 请注意任何从 Google 来到这里并寻找 OP 收到的错误消息的人:如果您仍在使用 nib 文件,则迁移到 Storyboards 实际上是解决方案。

标签: iphone appdelegate


【解决方案1】:

将 UIApplicationMain() 函数的最后一个参数 (nil) 替换为应用委托类的名称。一般默认为@"AppDelegate"。

【讨论】:

    【解决方案2】:

    如果其他人像我一样发现这个,您实际想要替换 nil 的代码是 NSStringFromClass([AppDelegate class]),如果您的命名不同,您可以将 AppDelegate 替换为您的类名。

    另外,别忘了#import "AppDelegate.h"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-31
      • 2013-06-03
      相关资源
      最近更新 更多