Первый способ применения Iphone

Какой метод вызывается первым, когда выполняется любое приложение Iphone?

5 ответов

Решение

Я полагаю

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

в main.m файл

Но для практических целей я думаю, что вам, как правило, необходимо реализовать некоторые методы UIApplicationDelegate, в зависимости от ситуации:

application:didFinishLaunchingWithOptions:
applicationDidBecomeActive:
applicationWillEnterForeground:

Если A View запускается, то это:

- (void)viewDidLoad {}

Если приложение запускается, это:

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

или же

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

Я думаю, вам лучше использовать метод ViewDidLoad.

Я надеюсь, что помог!

На самом деле:

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

приходит раньше:

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

Первая функция, вызываемая при запуске приложения

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

При запуске приложения вызывается прежде всего приложение:didFinishLaunchingWithOptions: метод..

После того, как представление запущено

в это время viewDidLoad выполняется;

Посмотрите на изображение Согласно Apple Doc

  • (BOOL) приложение:(UIApplication *) приложение willFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}

вызывается раньше

  • (BOOL) приложение:(UIApplication *) приложение didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}
Другие вопросы по тегам