我有一个苹果手表的复杂功能和 iPhone 应用程序并排运行。我在应用程序中有一个按钮,可以将应用程序上下文字典传输到手表。我希望看到并发症标题被刷新。
我似乎无法强制执行“点击按钮-> 查看并发症的更新”这种行为。
什么是强制更新并发症的适当方法?如何立即刷新我的 Apple Watch 复杂功能?
我确实看到了标题的变化,但我认为它需要我先点击复杂功能才能打开它的 Apple Watch 应用程序。如何让复杂功能在 Watch 主屏幕上自行更新?
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
if complication.family == .graphicRectangular {
let template = CLKComplicationTemplateGraphicRectangularLargeImage()
//...configure
return template
}
}
我看到这个苹果提供的代码刷新了复杂性。我不确定它是否太多,或者如果extendTimeline
我使用上面的条目生成并发症,单独调用是否就足够了。
func refreshComplication() {
#if os(watchOS)
let server = CLKComplicationServer.sharedInstance()
if let complications = server.activeComplications {
for complication in complications {
// Call this method sparingly. If your existing complication data is still valid,
// consider calling the extendTimeline(for:) method instead.
server.reloadTimeline(for: complication)
}
}
#endif
}