正确使用 UIApplicationMain

发布于 2024-09-03 02:36:36 字数 271 浏览 4 评论 0原文

我决定以编程方式加载我的视图,因此输入:

int ret = UIApplicationMain(argc, argv, nil, nil);

行不通。不过,我确实有一个 ViewController 和一个 AppDelegate。使用 ViewController 和 AppDelegate 时 UIApplicationMain 的正确用法是什么。
PS 我没有使用 XCode 或 Interface Builder,我正在工具链上进行开发。

I have decided to load my views programmatically, so putting:

int ret = UIApplicationMain(argc, argv, nil, nil);

Would not work. I do have a ViewController and an AppDelegate, though. What would be the proper use of UIApplicationMain to use a ViewController and an AppDelegate.
PS I am NOT using XCode or Interface Builder, I am developing on the toolchain.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧瑾黎汐 2024-09-10 02:36:36

此函数声明为

int UIApplicationMain (
   int argc,
   char *argv[],
   NSString *principalClassName,
   NSString *delegateClassName
);

由于您没有子类化 UIApplication,因此将 nil 传递给第三个参数。但是你有一个自定义的 UIApplicationDelegate。因此将其类名传递给第四个参数。

int retval = UIApplicationMain(argc, argv, nil, @"AppDelegate");

This function is declared as

int UIApplicationMain (
   int argc,
   char *argv[],
   NSString *principalClassName,
   NSString *delegateClassName
);

Since you did not subclass UIApplication, pass nil to the 3rd argument. But you have a custom UIApplicationDelegate. So pass its class name to the 4th argument.

int retval = UIApplicationMain(argc, argv, nil, @"AppDelegate");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文