【发布时间】:2018-11-18 20:00:17
【问题描述】:
我有一个 Apple Watch 复杂功能和 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
}
【问题讨论】:
标签: ios12 apple-watch-complication watchos-5