Search code examples
iosobjective-ciphoneapple-watchwatchos

viewDidLoad not called when using a WatchOS App


I am finalising a watchOS App, but am having difficulties to get the iPhone App to work when the watchApp has made a request.

It seems that the App loads in the background on the data request from the Apple Watch. However, if I then (within the time the App is still in the background) open the App the view is showing, but without going through the normal initiation like calling viewDidLoad.

How can I properly load the view in this case, when I launch the App when already loaded through an external process like the Apple Watch?

The reason I need to initialise the view is because it is populated by the database.

[edit:] The Application is a normal Storyboard application. The initial view controller is a UINavigationController which loads an UIViewController as rootViewController.

This is done 'automatic' by the specification in the Ap settings. My feeling is that because the storyboard seems to be loaded in the background the RootViewController class is not loaded for some reason.


Solution

  • The ViewDidLoad procedure was actually called, but the viewDidAppear is not if the App comes form the background. So it is possible to create a notification listener in the viewDidLoad to listen for the application to come out of background mode.