Ios WatchOS:HKWorkoutSession在第二个应用程序(如NRC或Runtastic)启动时结束
我正在测试来自苹果的SpeedySloth演示应用程序: 好了,这就到此结束了,每当第二个应用程序启动时:Ios WatchOS:HKWorkoutSession在第二个应用程序(如NRC或Runtastic)启动时结束,ios,swift,objective-c,cocoa,watchos,Ios,Swift,Objective C,Cocoa,Watchos,我正在测试来自苹果的SpeedySloth演示应用程序: 好了,这就到此结束了,每当第二个应用程序启动时: // MARK: - HKWorkoutSessionDelegate extension WorkoutManager: HKWorkoutSessionDelegate { func workoutSession(_ workoutSession: HKWorkoutSession, didChangeTo toState: HKWorkoutSessionState,
// MARK: - HKWorkoutSessionDelegate
extension WorkoutManager: HKWorkoutSessionDelegate {
func workoutSession(_ workoutSession: HKWorkoutSession, didChangeTo toState: HKWorkoutSessionState,
from fromState: HKWorkoutSessionState, date: Date) {
// Wait for the session to transition states before ending the builder.
/// - Tag: SaveWorkout
if toState == .ended {
print("The workout has now ended.")
builder.endCollection(withEnd: Date()) { (success, error) in
self.builder.finishWorkout { (workout, error) in
// Optionally display a workout summary to the user.
self.resetWorkout()
}
}
}
}
代表直接被调用为toState=。当我按下Nike Running Club中的“开始”按钮时结束。我假设,一次只能进行一次锻炼,但我可以使用阿迪达斯与NRC一起跑步,因此,这一定是有可能的。HKWorkoutSession的文档说明,一次只能进行一次锻炼 Apple Watch一次运行一次训练课程。如果第二个训练在你的训练运行时开始,你的HKWorkoutSessionLegate对象将收到HKError.Code.error另一个WorkoutSessionStarted错误,你的训练将结束 看
在Apple Watch发布之前,有几个应用程序允许用户使用CoreMotion API测量跑步或步行会话。我怀疑你提到的某个应用程序如果已经在运行训练课程,可能会回到这个问题上。听起来很合理,但我不确定Runtastic在CoreMotion的背景下如何计算心率。