我正在尝试使用HKWorkoutSession
开始训练课程。它没有启动会话。
let workoutConfiguration = HKWorkoutConfiguration()
workoutConfiguration.activityType = .running
workoutConfiguration.locationType = .outdoor
do {
session = try HKWorkoutSession(healthStore: healthStore!, configuration: workoutConfiguration)
session?.delegate = self
session?.startActivity(with: Date())
print((session?.state)!.rawValue)
} catch let error {
print(error)
}
HKWorkoutSessionDelegate
方法func workoutSession(_ workoutSession: HKWorkoutSession, didChangeTo toState: HKWorkoutSessionState, from fromState: HKWorkoutSessionState, date: Date)
永远不会接到电话。
最佳答案
我已经看过几次了(不足以重现或做任何事情)。
我认为重启Xcode和模拟器有帮助。