我使用reloadRootPageControllers加载4个InterfaceControllers,我需要将一个上下文传递给每个,但是使用下面的代码,只有数组中的第一个InterfaceController接收上下文。我如何将它传递给所有4个?
let contextDictionary = ["workoutConfiguration" : workoutConfiguration, "ActivityType": selectedActivityType, "workoutManager" : workoutManager] as [String : Any]
WKInterfaceController.reloadRootPageControllers(withNames: ["WorkoutControlsInterfaceController", "MainDisplayInterfaceController", "SpeedInterfaceController", "CaloriesAndDistanceInterfaceController"],
contexts: [contextDictionary],
orientation: .horizontal,
pageIndex: 1)
答案 0 :(得分:1)
您需要使用与contextDictionary
数组withNames
相同的数组。
WKInterfaceController.reloadRootPageControllers(withNames: ["WorkoutControlsInterfaceController", "MainDisplayInterfaceController", "SpeedInterfaceController", "CaloriesAndDistanceInterfaceController"],
contexts: [contextDictionary, contextDictionary, contextDictionary, contextDictionary],
orientation: .horizontal,
pageIndex: 1)