Я пытаюсь создать приложение для тренировки, следуя этому видео WWDC от apple , к сожалению, некоторые методы уже устарели в WatchOS 4, и я не могу заставить код работать.каждый раз, когда я нажимаю одну из кнопок, чтобы начать тренировку, экран становится черным, и я получаю ошибку Extension[11692:537762] [default] -[SPApplicationDelegate companionConnection:reloadRootInterfaceViewControllersWithNames:initializationContextIDs:pageIndex:verticalPaging:]:1432: Error - interface does not define view controller class 'WorkoutInterfaceController'
, второй контроллер представления «WorkoutInterfaceController» находится в раскадровке и связан с его классом.
мой класс WKInterfaceController:
class InterfaceController: WKInterfaceController {
@IBOutlet var outdoorBtn: WKInterfaceButton!
@IBOutlet var indoorBtn: WKInterfaceButton!
override func awake(withContext context: Any?) {
super.awake(withContext: context)
// Configure interface objects here.
}
override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
}
override func didDeactivate() {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
}
@IBAction func didTapOutdoorButton() {
let workoutConfiguration = HKWorkoutConfiguration()
workoutConfiguration.activityType = .walking
workoutConfiguration.locationType = .outdoor
// Pass configuration to next interface controller
WKInterfaceController.reloadRootPageControllers(withNames: ["WorkoutInterfaceController"], contexts: [workoutConfiguration], orientation: .horizontal, pageIndex: 0)
}
@IBAction func didTapIndoorSaButton() {
let workoutConfiguration = HKWorkoutConfiguration()
workoutConfiguration.activityType = .walking
workoutConfiguration.locationType = .indoor
// Pass configuration to next interface controller
WKInterfaceController.reloadRootPageControllers(withNames: ["WorkoutInterfaceController"], contexts: [workoutConfiguration], orientation: .horizontal, pageIndex: 0)
}
}
Буду очень признателен за помощь!