当任何 iOS 应用程序启动时,首先调用哪个方法和函数?

发布于 2024-10-18 04:11:39 字数 35 浏览 3 评论 0原文

当任何 iOS 应用程序启动时,首先调用哪个方法和函数?

Which method and function is called first when any iOS application start ?

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

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

发布评论

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

评论(6

巡山小妖精 2024-10-25 04:11:39

我想它

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

main.m 文件中,

但出于实际目的,我认为您通常需要实现一些 UIApplicationDelegate 的方法,具体取决于情况:

application:didFinishLaunchingWithOptions:
applicationDidBecomeActive:
applicationWillEnterForeground:

I suppose its

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

in main.m file

But for practical purposes I think you usually need to implement some of the UIApplicationDelegate's methods, depending on situation:

application:didFinishLaunchingWithOptions:
applicationDidBecomeActive:
applicationWillEnterForeground:
征棹 2024-10-25 04:11:39

如果 View 启动,则为:

- (void)viewDidLoad {}

如果 app 启动,则为:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:

或者

- (void)applicationWillEnterForeground:(UIApplication *)application {

我认为您最好使用 ViewDidLoad 方法。

我希望我有所帮助!

If A View starts up, then it's:

- (void)viewDidLoad {}

If an app starts up it's:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:

or

- (void)applicationWillEnterForeground:(UIApplication *)application {

I think you'l be better of using the ViewDidLoad Method.

I hope i helped!

只有影子陪我不离不弃 2024-10-25 04:11:39

实际上:

- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}

出现在:之前

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}

actually:

- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}

comes before:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}
岁月无声 2024-10-25 04:11:39

应用启动期间调用的第一个函数

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

应用启动期间调用的第一个方法

application( _:willFinishLaunchingWithOptions:)

UIKit 处理大部分应用程序启动任务。

1) The app is launched, either explicitly by the user or implicitly by the system.

2) The Xcode-provided main function calls UIKit's UIApplicationMain() function.

3) The UIApplicationMain() function creates the UIApplication object and your app delegate.

4) UIKit loads your app's default interface from the main storyboard or nib file.

5) UIKit calls your app delegate's application(_:willFinishLaunchingWithOptions:) method.

6) UIKit performs state restoration, which calls additional methods of your app delegate and view controllers.

7) UIKit calls your app delegate's application(_:didFinishLaunchingWithOptions:) method.

应用程序启动和初始化序列

参考 - https://developer. apple.com/documentation/uikit/app_and_environment/responding_to_the_launch_of_your_app/about_the_app_launch_sequence

First function called during app launch

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

First method called during app launch

application(_:willFinishLaunchingWithOptions:)

UIKit handle most of app launch tasks.

1) The app is launched, either explicitly by the user or implicitly by the system.

2) The Xcode-provided main function calls UIKit's UIApplicationMain() function.

3) The UIApplicationMain() function creates the UIApplication object and your app delegate.

4) UIKit loads your app's default interface from the main storyboard or nib file.

5) UIKit calls your app delegate's application(_:willFinishLaunchingWithOptions:) method.

6) UIKit performs state restoration, which calls additional methods of your app delegate and view controllers.

7) UIKit calls your app delegate's application(_:didFinishLaunchingWithOptions:) method.

The app launch and initialization sequence

Reference - https://developer.apple.com/documentation/uikit/app_and_environment/responding_to_the_launch_of_your_app/about_the_app_launch_sequence

离笑几人歌 2024-10-25 04:11:39

当应用程序启动时,首先 application:didFinishLaunchingWithOptions:
方法被调用。

视图启动后

,viewDidLoad 被执行;

when application launches, first of all application:didFinishLaunchingWithOptions:
method is called..

After when view is launched

at that time viewDidLoad is executed;

风铃鹿 2024-10-25 04:11:39

查看图像根据苹果文档

  • (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:( NSDictionary *)launchOptions{}

之前被调用

  • 在(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}

Have look at image According to apple doc

  • (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}

gets called before

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文