Quelle méthode et quelle fonction est appelée d'abord lorsque une application iOS commence?

StackOverflow https://stackoverflow.com/questions/5039960

  •  15-11-2019
  •  | 
  •  

Question

Quelle méthode et quelle fonction est appelée d'abord lorsque une application iOS commence?

Était-ce utile?

La solution

Je suppose que c'est

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

dans main.m dossier

Mais à des fins pratiques, je pense que vous devez généralement mettre en œuvre certaines des méthodes de l'UIApplicationdelegate, selon la situation:

application:didFinishLaunchingWithOptions:
applicationDidBecomeActive:
applicationWillEnterForeground:

Autres conseils

Si un Voir démarre, alors c'est:

- (void)viewDidLoad {}

Si un appliquer démarre c'est:

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

ou

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

Je pense que vous ferez mieux d'utiliser le ViewDidload Méthode.

J'espère que j'ai aidé!

réellement:

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

vient avant:

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

Lorsque l'application sera lancée, tout d'abord l'application: DidFinishlAunchingWithOptions: La méthode est appelée ..

Après quand la vue est lancée

À ce moment-là, ViewDidload est exécuté;

Avoir un regard sur l'image Selon Apple Doc

  • (Bool) Application: (UIApplication *) Application WillFinishLaunchingWithOptions: (nsdictionary *) LaunchOptions {}

est appelé avant

  • (Bool) Application: (UIApplication *) Application DidfinishlaunchingWithOptions: (nsdictionary *) LaunchOptions {}

Première fonction appelée lors du lancement de l'application

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

Première méthode appelée lors du lancement de l'application

application(_:willFinishLaunchingWithOptions:)

Uikit gère la plupart des tâches de lancement d'applications.

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

Référence - https://developer.apple.com/documentation/uikit/app_and_environment/responding_to_the_launch_of_your_app/about_the_app_launch_sequence

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top