AppleWatch上的Swift:reloadTimeline(用于复杂化)冻结UI
创始人
2024-09-11 01:00:15
0

添加DispatchQueue.main.async{}块来确保在主线程上更新UI。示例代码:

func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) { print("getCurrentTimelineEntry") let now = Date() let entry = getTimelineEntry(for: complication, date: now) handler(entry) }

func getTimelineEntry(for complication: CLKComplication, date: Date) -> CLKComplicationTimelineEntry { let template = complication.template // Customize the template to display relevant information for the date. template.textProvider = CLKSimpleTextProvider(text: "Hello World") // Call the reloadTimeline(for:) method for a complication on demand. DispatchQueue.main.async { // Add this block to update UI complication.reloadTimeline(for: complication) } return CLKComplicationTimelineEntry(date: date, complicationTemplate: template) }

相关内容

热门资讯

原来有开挂!开心十三张技巧(透... 原来有开挂!开心十三张技巧(透视)拱趴大菠萝万能挂(专业教程开挂辅助平台)【无需打开直接搜索加薇13...
原生有开挂"丫丫老陕... 原生有开挂"丫丫老陕开挂"开挂(透视)辅助软件(黑科技教程有挂分享) >>您好:软件加薇136704...
推荐开挂!小闲54辅助(透视)... 大家好,今天小编来为大家解答sohoopoker辅助这个问题咨询软件客服可以免费测试直接加微信(13...
固有有开挂"贰柒拾智... 固有有开挂"贰柒拾智能辅助柒"开挂(透视)辅助工具(分享教程果真有挂);无需打开直接搜索微信(136...
分享开挂!广东雀神智能插件试用... 分享开挂!广东雀神智能插件试用免费(透视)wepoker轻量版透视系统(存在挂教程开挂辅助软件)>>...
原先有辅助"广丰中至... 原先有辅助"广丰中至510k辅助"开挂(透视)辅助插件(爆料教程新版有挂)广丰中至510k辅助ai黑...
必看开挂!hhpoker怎么防... 您好:hhpoker怎么防辅助这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多...
固有有辅助"广东雀神... 固有有辅助"广东雀神智能插件使用"开挂(透视)辅助透视(专业教程有挂方式);无需打开直接搜索打开薇:...
通报辅助!中至九江都昌讨赏插件... 通报辅助!中至九江都昌讨赏插件(透视)wepoker破解器有用吗(实用技巧开挂辅助脚本);打开点击测...
起初有辅助"新道游透... 起初有辅助"新道游透视黑科技"开挂(透视)辅助平台(玩家教程果真有挂)您好:新道游透视黑科技这款游戏...