2

I'm loading up 4 WKInterfaceControllers into a page based horizontal interface in watchKit. enter image description here When a delegate callback fires alerting the app that the screen has been water locked, I want the watch to segue to one of the Controllers (based on a user setting). Using the code below, if the delegate fires upon water lock, the app will segue to MainDisplayInterfaceController as expected. However, if the delegate fires in either of the other two interfaceControllers the screen appears to segue but then settles back on the original WorkoutControlsInterfaceController (i.e. 0) however the page control on bottom of the screen is on 2 of 4? Could this be a WatchKit bug?

EDIT: one clue I noticed is that on the first water lock I get the above behavior. But if I unlock and then lock again, I get the expected behavior.

 class ConfigureWorkoutInterfaceController: WKInterfaceController {
       WKInterfaceController.reloadRootPageControllers(withNames: ["WorkoutControlsInterfaceController", "MainDisplayInterfaceController", "SpeedInterfaceController", "CaloriesAndDistanceInterfaceController"],
                                                            contexts: [contextDictionary, contextDictionary, contextDictionary, contextDictionary],
                                                            orientation: .horizontal,
                                                            pageIndex: 1)
        }
    }

    extension MainDisplayInterfaceController: WaterLockStateDelegate {
        func didUpdateWaterLockState(_ manager: WorkoutManager, state: Bool) {
                     DispatchQueue.main.async {
                        self.becomeCurrentPage()
                    }
        }


    }

    extension SpeedInterfaceController: WaterLockStateDelegate {
        func didUpdateWaterLockState(_ manager: WorkoutManager, state: Bool) {
                     DispatchQueue.main.async {
                        self.becomeCurrentPage()
                    }

    }

    extension CaloriesAndDistanceInterfaceController: WaterLockStateDelegate {
        func didUpdateWaterLockState(_ manager: WorkoutManager, state: Bool) {
                     DispatchQueue.main.async {
                        self.becomeCurrentPage()
                    }
    }
GarySabo
  • 5,806
  • 5
  • 49
  • 124

0 Answers0