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

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

问题描述

我的应用程序有问题..我尝试遵循一些指南,例如

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天全站免登陆