我有一个非常简单的并发症随机数。 但我的号码不会更新。我每次看表都是一样的。只有重新安装复杂功能(重新安装苹果手表应用程序),我才能获得新号码。
我已将更新设置为1秒。任何人都知道什么可能是错的?
overflow:hidden;
transform: rotateZ(0deg) skew(0deg); }
答案 0 :(得分:2)
您的数据来源遗失the methods that are responsible for handling the scheduled update。
在计划更新开始时,ClockKit会调用
var d = new Date(); var h = d.getHours(); // and you have the current hours stored in a variable named h; // now you can compare the hour with whatever you want and do whatever you want, e.g: if (0 <= d <= 6 || 18 <= d <= 23) { alert("it's night."); } else { alert("it's day.") }; //changing background: if (0 <= d <= 6 || 18 <= d <= 23) { document.getElementById("columnId").style.background = "blue"; } else { document.getElementById("column2Id").style.background = "yellow"; };
或requestedUpdateDidBegin
方法,具体取决于并发症的时间预算状态。 如果要将数据添加到时间轴,则必须实施其中一种或两种方法。您对这些方法的实现应根据需要扩展或重新加载并发症的时间轴。当您这样做时,ClockKit会从您的数据源请求新的时间轴条目。如果您没有延长或重新加载时间线,ClockKit不会要求任何新的时间表条目。
以下是您在计划更新后重新加载时间轴的方法:
requestedUpdateBudgetExhausted
您还应该实施// MARK: - Responding to Scheduled Updates
func requestedUpdateDidBegin() {
let server=CLKComplicationServer.sharedInstance()
for complication in server.activeComplications {
server.reloadTimelineForComplication(complication)
}
}
。
请记住,预定的更新只能每10分钟发生一次;它不可能每秒更新你的并发症。另外,请考虑更新频率可能会耗尽更新预算:
指定您可以管理的日期。不要让系统在几分钟内更新您的并发症。相反,提供持续数小时或一整天的数据。如果您的预算用尽,则在您的预算补充完毕之后才会进行下一次预定更新。