天道酬勤,学无止境

clockkit

如何使用来自complicationController的sendMessage唤醒iOS父应用程序(how to wake up iOS parent app with sendMessage from complicationController)

问题 我正在尝试通过从 watchkit 扩展发送消息来唤醒 iOS 父应用程序。 这只有在从 watchApp / ViewController 调用下面的 sendMessage 函数时才有效。 当从 ComplicationController 调用它时,会发送消息,但 iOS 父应用程序现在确实会唤醒。 任何建议表示赞赏。 (请在 Swift 中引用任何代码) 这里的简化代码: 在 AppDelegate 和 ExtensionDelegate 中: override init() { super.init() setupWatchConnectivity() } private func setupWatchConnectivity() { if WCSession.isSupported() { let session = WCSession.defaultSession() session.delegate = self session.activateSession() } } 在 ExtensionDelegate 中:(这里没问题,消息发送成功) func sendMessage(){ let session = WCSession.defaultSession() let applicationData:[String:AnyObject] = ["text"

2022-01-13 11:56:41    分类:技术分享    ios   iphone   swift2   apple-watch-complication   clockkit

how to wake up iOS parent app with sendMessage from complicationController

I am trying to wake up the iOS parent app by sending a message from watchkit extension. This though does only work when below sendMessage function is called from the watchApp / ViewController. When it is called from ComplicationController, the message is sent, but the iOS parent app does now wake up. Any advice appreciated. (please any code reference in Swift) Here the simplified code: In AppDelegate and ExtensionDelegate: override init() { super.init() setupWatchConnectivity() } private func setupWatchConnectivity() { if WCSession.isSupported() { let session = WCSession.defaultSession()

2022-01-11 11:50:18    分类:问答    ios   iphone   swift2   apple-watch-complication   clockkit

获取数据复杂化:未调用 ExtensionDelegate(Get Data to Complication: ExtensionDelegate not Called)

问题 (看起来这个问题在前几周已经被其他人遇到了,但我还没有找到任何解决方案。) 我正在尝试做一件非常基本的事情:从我的 iOS 应用程序或我的 Watch 应用程序获取数据到我的 Complication Controller。 事实证明,我完成这件事的能力比我想象的要差得多。 watchOS 2 Transition Guide 指出我应该使用以下代码“[获取]来自扩展委托的所需数据”: ExtensionDelegate* myDelegate = [[WKExtension sharedExtension] delegate]; NSDictionary* data = [myDelegate.myComplicationData objectForKey:ComplicationCurrentEntry]; 伟大的。 除了,我一直无法弄清楚如何让它在扩展端工作。 尽管更重要的是,我似乎甚至无法从复杂控制器启动中运行扩展委托代码。 当我运行复杂功能时,我收到以下消息:“扩展收到唤醒复杂功能支持的请求。” 但是,任何扩展委托的方法中的代码似乎都没有运行。 我还在每个方法中设置了断点,并且没有一个断点被命中。 它看起来也像“transferCurrentComplicationUserInfo:”也被建议用于复杂功能更新,尽管目前还不清楚它是如何使用的。 据我所知

2021-12-21 10:54:48    分类:技术分享    apple-watch   watchos-2   apple-watch-complication   clockkit

Get Data to Complication: ExtensionDelegate not Called

(It looks like this issue has been encountered by others in previous weeks, but there haven't been any solutions that I've found.) I'm trying to do a really basic thing: Get data from either my iOS app or my Watch app to my Complication Controller. I am turning out to be way less capable of getting this done than I thought. watchOS 2 Transition Guide indicates that I should "[fetch] the needed data from the extension delegate" using the following code: ExtensionDelegate* myDelegate = [[WKExtension sharedExtension] delegate]; NSDictionary* data = [myDelegate.myComplicationData objectForKey

2021-12-12 12:20:45    分类:问答    apple-watch   watchos-2   apple-watch-complication   clockkit

watchOS - 复杂功能显示以前的条目(watchOS - Complication shows previous entry)

问题 我正在创建一个 watchOS 3 复杂功能,用于显示公共交通服务的出发时间。 我用一个数组创建了一个数据模型,该数组包含带有stationName (String) 和departureTime (NSDate) 的Train对象。 我已经实现了 getCurrentTimelineEntry() 方法并且条目显示在手表上。 问题是手表只显示上一个条目。 例如,我有以下出发时间: Train(startStation: "Station name", endStation: "Station name", departureTime: stringToDate(dateString: "2016-06-20 14:00")), Train(startStation: "Station name", endStation: "Station name", departureTime: stringToDate(dateString: "2016-06-20 14:30")), Train(startStation: "Station name", endStation: "Station name", departureTime: stringToDate(dateString: "2016-06-20 14:45")), 如果当前时间为 14:10,则手表上仍显示第一个条目

2021-10-14 23:52:33    分类:技术分享    swift   watchkit   apple-watch-complication   clockkit   watchos-3

为 Apple Watch 复杂功能设置 tintColor(Setting tintColor for Apple Watch complication)

问题 我正在尝试为模块化大型复杂功能设置标题文本颜色。 我已经自定义了表盘以使用多色。 但是,当我构建并运行此代码时,标题文本颜色仍然是白色(这是默认值)。 为什么不更新颜色? private func templateForClassModularLarge(className: Schedule) -> CLKComplicationTemplateModularLargeStandardBody { let template = CLKComplicationTemplateModularLargeStandardBody() let headerTextProvider = CLKSimpleTextProvider(text: "My Schedule", shortText: "Schedule") headerTextProvider.tintColor = UIColor(red: 101, green: 153, blue: 255, alpha: 1) template.headerTextProvider = headerTextProvider template.body1TextProvider = CLKTimeIntervalTextProvider(startDate: className.start, endDate: className.end)

2021-10-14 21:33:16    分类:技术分享    swift   watchos   apple-watch-complication   clockkit

watchOS - Complication shows previous entry

I'm creating a watchOS 3 complication that shows departure times from a public transit service. I've created a data model with an array that contains Train objects with a stationName (String) and departureTime (NSDate). I've implemented the getCurrentTimelineEntry() method and the entries are showing on the watch. The problem is that the watch shows only the previous entry. For example, I've the following departure times: Train(startStation: "Station name", endStation: "Station name", departureTime: stringToDate(dateString: "2016-06-20 14:00")), Train(startStation: "Station name", endStation:

2021-10-12 12:18:42    分类:问答    swift   watchkit   apple-watch-complication   clockkit   watchos-3

Setting tintColor for Apple Watch complication

I am trying to set the header text color for a Modular Large complication. I have already customized the watch face to use Multicolor. However, when I build and run this code, the header text color is still white (which is the default). Why isn't the color updating? private func templateForClassModularLarge(className: Schedule) -> CLKComplicationTemplateModularLargeStandardBody { let template = CLKComplicationTemplateModularLargeStandardBody() let headerTextProvider = CLKSimpleTextProvider(text: "My Schedule", shortText: "Schedule") headerTextProvider.tintColor = UIColor(red: 101, green: 153

2021-10-11 09:36:19    分类:问答    swift   watchos   apple-watch-complication   clockkit

ClockKit CLKComplicationDataSource 缺少向后事件(ClockKit CLKComplicationDataSource missing backward events)

问题 我编写了一个带有并发症支持的测试应用程序 出于某种原因,钟面仅显示 1-2 个向后事件,但我可以在当前日期之前的日志中看到 10-15 个事件。 当我为前向事件返回一个空数组时,我所有的后向事件都开始显示在钟面上。 这是我的功能 func getTimelineEntriesForComplication(complication: CLKComplication, beforeDate date: NSDate, limit: Int, withHandler handler: (([CLKComplicationTimelineEntry]?) -> Void)) { var entries: [CLKComplicationTimelineEntry] = [] let events = self.events.filter { (event: CEEvent) -> Bool in return date.compare(event.startDate) == .OrderedDescending } var lastDate = date.midnightDate for event in events { let entry = CLKComplicationTimelineEntry(date: lastDate, complicationTemplate

2021-10-10 15:44:33    分类:技术分享    ios   apple-watch   apple-watch-complication   time-travel   clockkit

ClockKit CLKComplicationDataSource missing backward events

I write a test app with complications support For some reason clock faces presenting only 1-2 backward events, but I can see in logs 10-15 events before current date. And when I return an empty array for forward events all my backward events start showing in clock face. Here is my function func getTimelineEntriesForComplication(complication: CLKComplication, beforeDate date: NSDate, limit: Int, withHandler handler: (([CLKComplicationTimelineEntry]?) -> Void)) { var entries: [CLKComplicationTimelineEntry] = [] let events = self.events.filter { (event: CEEvent) -> Bool in return date.compare

2021-10-10 15:15:37    分类:问答    ios   apple-watch   apple-watch-complication   time-travel   clockkit