本文介绍了如何将某些消息或字符串从iPhone设备传递到配对的Apple Watch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何将特定的消息或字符串从我的iPhone设备传递到配对的iWatch.我真的很想知道从开发的角度来看这是如何处理的.是否有任何特定的WKInterfaceController方法或API将信息从iPhone传递到iWatch?

I would like to know how a particular message or string can be passed from my iPhone device to the paired iWatch. I would really like to know how this is handled from development point of view. Is there any particular WKInterfaceController method or API which passes the info from iPhone to iWatch?

我已经在开发人员论坛上阅读了openParentApplication:reply:从iWatch通知iPhone应用程序,以及application:handleWatchKitExtensionRequest:reply处理iPhone上的特定通知请求.但是我要相反.

I have read on developer forum that openParentApplication:reply: notifies the iPhone application from iWatch and application:handleWatchKitExtensionRequest:reply handles that particular notification request on iPhone. But I want the reverse.

可以说,我有一个带有UITextField和UIButton的iPhone应用程序故事板场景.用户输入你好!"在文本字段上,然后单击按钮.现在,我在同一个项目中使用iwatch故事板扩展了手表套件.此故事板场景具有"WKInterfaceLabel".我想让我的iPhone控制器与WKInterfaceController交互,以便可以在iphone滑板上输入的消息(在本例中为"Hello!")可以传递到iWatch控制器并显示在iWatch上.

Lets say, I have an iPhone application storyboard scene with a UITextField and UIButton. User enters "Hello !" on text field and clicks on button. Now I have a watch kit extension within the same project with an iwatch storyboard. This storyboard scene has an "WKInterfaceLabel". I would like to have my iPhone controller interact with WKInterfaceController so that the message entered on iphone stroyboard ("Hello !" in this case) can be passed to the iWatch controller and displayed on the iWatch.

推荐答案

为了从iPhone与手表进行通讯,您需要使用应用程序组和darwin通知.您可以使用MMWormhole(在此处可用)进行此操作.

In order to communicate from iPhone to your watch, you need to use app groups, and darwin notifications. You can use MMWormhole (available here) to do this.

这篇关于如何将某些消息或字符串从iPhone设备传递到配对的Apple Watch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 07:40