我正在測驗蘋果公司的SpeedySloth演示應用程式。https://developer.apple.com/documentation/healthkit/workouts_and_activity_rings/speedysloth_creating_a_workout
好吧,這就結束了,每當第二個應用程式開始時:
// MARK: - HKWorkoutSessionDelegate
extension WorkoutManager。HKWorkoutSessionDelegate {
func workoutSession(_ workoutSession: HKWorkoutSession, didChangeTo toState: HKWorkoutSessionState,
from fromState: HKWorkoutSessionState, date: Date) {
//等待會話轉換狀態后再結束構建器。
/// - Tag: SaveWorkout
if toState == .end {
print("The workout has now ended." )
builder.endCollection(withEnd: Date() { (success, error) in.
self.builder.finishWorkout { (workout, error) in.
//可選擇向用戶顯示一個鍛煉的總結。
self.resetWorkout()
}
}
}
當我在Nike Running Club中按下 "開始 "按鈕時,該委托被直接呼叫,toState = .end。我認為一次只能進行一次鍛煉,但我可以在使用NRC的同時使用Adidas Running,所以,這一定是有可能的。
uj5u.com熱心網友回復:
HKWorkoutSession的檔案指出,一次只能運行一個。
Apple Watch每次運行一個鍛煉會話。如果在您的鍛煉正在運行時,第二個鍛煉開始了,您的 HKWorkoutSessionDelegate 物件會收到 HKError.Code.errorAnotherWorkoutSessionStarted 錯誤,并且您的鍛煉結束。
參見https://developer.apple.com/documentation/healthkit/hkworkoutsession
在Apple Watch問世之前,有幾個應用程式允許用戶通過使用CoreMotion APIs來測量跑步或步行會話。我懷疑你提到的其中一個應用程式可能會在一個鍛煉會話已經在運行的情況下回傳到這一點。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/320055.html
標籤:
