小编use*_*227的帖子

无法在WatchOS 3中更新Apple Watch并发症

我无法在WatchOS 3中更新或刷新Apple Watch Complication。我在ComplicationController.swift文件中使用以下代码。

func getSupportedTimeTravelDirections(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimeTravelDirections) -> Void) {
    handler([.forward])
}

func getTimelineStartDate(for complication: CLKComplication, withHandler handler: @escaping (Date?) -> Void) {
    handler(Date())
}

func getTimelineEndDate(for complication: CLKComplication, withHandler handler: @escaping (Date?) -> Void) {
    handler(Date(timeIntervalSinceNow: 60 * 30))
}
Run Code Online (Sandbox Code Playgroud)

我也曾尝试从中的handle后台任务方法安排更新,ExtensionDelegate.swift但它似乎也不起作用。

func scheduleNextRefresh() {
    let fireDate = Date(timeIntervalSinceNow: 30 * 60)
    let userInfo = ["lastActiveDate" : Date(),
                    "reason" : "updateWeekNumber"] as Dictionary

    WKExtension.shared().scheduleBackgroundRefresh(withPreferredDate: fireDate, userInfo: userInfo as NSSecureCoding) { (error) …
Run Code Online (Sandbox Code Playgroud)

ios swift watchkit clockkit watchos-3

2
推荐指数
1
解决办法
1595
查看次数

标签 统计

clockkit ×1

ios ×1

swift ×1

watchkit ×1

watchos-3 ×1