错误:已停止的锻炼会话无法重新启动 [英] Error : Stopped workout session cannot be restarted

查看:76
本文介绍了错误:已停止的锻炼会话无法重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以启动和停止 HealthKit 锻炼会话.但是,当我尝试停止第一次锻炼后再尝试第二次锻炼时,我会收到错误消息:

I can start and stop a HealthKit workout session. But when I try to start a second workout after my first has stopped, I get the error:

"workOutSession错误:无法重新启动已停止的锻炼会话"

"workOutSession Error : Stopped workout session cannot be restarted"

如何在不关闭并重新启动应用程序的情况下启动下一个锻炼会话(在第一个会话停止之后)?我正在使用 Xcode 7.2 IOS9.2 Watch OS 2.1

How do I start the next workout session (after the first has been stopped) without closing down and restarting the app? I am using Xcode 7.2, IOS9.2 and Watch OS 2.1

从InterfaceController停止:

Stopping from InterfaceController:

func startWorkout() {
    myExtensionConnectivity.startSession()
    myExtensionHealthKitManager.startWorkout()
    myExtensionConnectivity.sendStartUpdatingCommand()
    }

func stopWorkout() {
    myExtensionConnectivity.sendStopUpdatingCommand()
    myExtensionHealthKitManager.endWorkout()
    myExtensionConnectivity.stopSession()
    }

从HealthkitManager:

From HealthkitManager:

func endWorkout() {
    healthStore.endWorkoutSession(workoutSession)
}

func startWorkout() {
    healthStore.startWorkoutSession(workoutSession)
}

推荐答案

在开始第二次锻炼之前,您需要创建一个新的HKWorkoutSession实例.如错误消息所述,您可能无法重新启动已停止的会话.

You need to create a new HKWorkoutSession instance before starting the second workout. As the error message states, you may not re-start a stopped session.

这篇关于错误:已停止的锻炼会话无法重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆