将文本从 iOS 标签传递到 WatchOS 标签 - swift- [英] Pass text from iOS label to WatchOS label - swift-

查看:23
本文介绍了将文本从 iOS 标签传递到 WatchOS 标签 - swift-的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序有问题.我尝试遵循一些指南,例如 将数据传递给 Apple Watch 应用 ,但我不确定它是否适合我的情况.我的 iOS 应用程序上有一些带有文本的标签,然后我想在我的 watchOS 应用程序标签上显示此文本,但我不知道哪种方法是传递此文本并使其与 iOS 应用程序保持同步的最佳方式.非常感谢您的帮助!

I've a problem, with my app.. I try to follow some guide like Passing data to Apple Watch app , but I'm not sure it will fit for my case. I've some label with text on my iOS app, then I want to show this text on my watchOS app label, and I don't know which is the best way to pass this text and keep it synchronized with the iOS app.. Thanks a lot for your help!

推荐答案

从 watchOS2 开始,除了 WatchConnectivity 框架之外,你没有任何用于在 iOS 和 watchOS 应用程序之间进行通信的内置函数.

Since watchOS2, you don't have any built in function for communicating between the iOS and watchOS app than the WatchConnectivity framework.

根据您问题中提供的信息,updateApplicationContext(_:) 函数似乎是您问题的最佳解决方案.您可以使用此功能发送数据字典,系统会尝试确保在您的应用程序向用户显示时已收到数据.如果在应用对用户可见(在前台运行)之前多次调用该函数,系统会覆盖之前的数据,因此 Watch 应用只会接收要显示的最新数据.

From the information provided in your question, the updateApplicationContext(_:) function seems to be the best solution for your problem. You can send a dictionary of data with this function and the system tries to make sure that the data is received by the time your app is displayed to the user. If the function is called several times before the app would be visible to the user (run in the foreground), the system overwrites the previous data, so the Watch app only receives the most recent data to display.

这篇关于将文本从 iOS 标签传递到 WatchOS 标签 - swift-的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆