'WatchKit: Why is awakeWithContext not being called for all WKInterfaceControllers in my storyboard?
I have a page based WatchKit app with three WKInterfaceControllers in the storyboard each linked with a nextPage segue. For each controller I am logging when the awakeWithContext method is called.
On my Series 6 watch (running 8.4.2) and my Series 3 watch (also running 8.4.2) only the first two controller awakeWithContext methods are called when the app starts. When I swipe to the second page then the awake method is called for the third page - the log looks like this:
// App starts
Page 0 awakeWithContext
Page 1 awakeWithContext
Page 0 willActivate
Page 0 didAppear
// Swipe from page 0 to page 1
Page 0 didDeactivate
Page 1 willActivate
Page 2 awakeWithContext
Page 1 didAppear
Is this expected behaviour? All the things I have read say that awakeWithContext should be called for all the pages on start-up?
Another interesting thing is that if I navigate from Page 0 to Page 1 by calling becomeCurrentPage on Page 1 then awakeWithContext is not called on Page 2 at all. However if I manually swipe back to Page 0 and then back to Page 1 it is called.
All of this makes it impossible to navigate around the page structure of the app since I can't call becomeCurrentPage on Page 2 until it is loaded manually.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
