没有textnode的权威标签列表(Authoritative list of tags without textnode)
我正在寻找没有textnode的标签的权威列表,例如:
img
,br
等。I'm looking for an authoritative list of tags that don't have a textnode, e.g.:
img
,br
, etc.
原文:https://stackoverflow.com/questions/21613769
最满意答案
可达意味着苹果手表和iPhone通过蓝牙或WiFi连接。 这并不意味着iPhone应用程序正在运行。 如果可以访问,那么当您尝试从Apple Watch发送消息时,它会在后台启动iPhone应用程序。 您需要尽快分配WKSession委托,因为委托方法(sendMessage)很快就会触发。 我想你要说的是如果可以的话调用sendMessage,而不是使用transferUserInfo方法。 要做到这一点,首先在你的苹果手表上:
func applicationDidFinishLaunching() { let session = WCSession.defaultSession() session.delegate = self session.activateSession() // NOTE: This should be your custom message dictionary // You don't necessarily call the following code in // applicationDidFinishLaunching, but it is here for // the simplicity of the example. Call this when you want to send a message. let message = [String:AnyObject]() // To send your message. // You could check reachable here, but it could change between reading the // value and sending the message. Instead just try to send the data and if it // fails queue it to be sent when the connection is re-established. session.sendMessage(message, replyHandler: { (response) -> Void in // iOS app got the message successfully }, errorHandler: { (error) -> Void in // iOS app failed to get message. Send it in the background session.transferUserInfo(message) }) }
然后,在你的iOS应用程序中:
// Do this here so it is setup as early as possible so // we don't miss any delegate method calls func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { self.watchKitSetup() return true } func watchKitSetup() { // Stop if watch connectivity is not supported (such as on iPad) if (WCSession.isSupported()) { let session = WCSession.defaultSession() session.delegate = self session.activateSession() } } func session(session: WCSession, didReceiveMessage message: [String : AnyObject], replyHandler: ([String : AnyObject]) -> Void) { // Handle the message from the apple watch... dispatch_async(dispatch_get_main_queue()) { // Update UI on the main thread if necessary } } func session(session: WCSession, didReceiveUserInfo userInfo: [String : AnyObject]) { // Handle the message from the apple watch... dispatch_async(dispatch_get_main_queue()) { // Update UI on the main thread if necessary } }
Reachable means the apple watch and iPhone are connected via bluetooth or wifi. It doesn't necessarily mean the iPhone app is running. If reachable is true, when you try to sendMessage from the apple watch it will launch the iPhone app in the background. You need to assign the WKSession delegate as soon as possible because the delegates methods (sendMessage) will fire soon. I think what you are saying you want to do is call sendMessage if you can, and it not use the transferUserInfo method instead. To do this, first on your apple watch:
func applicationDidFinishLaunching() { let session = WCSession.defaultSession() session.delegate = self session.activateSession() // NOTE: This should be your custom message dictionary // You don't necessarily call the following code in // applicationDidFinishLaunching, but it is here for // the simplicity of the example. Call this when you want to send a message. let message = [String:AnyObject]() // To send your message. // You could check reachable here, but it could change between reading the // value and sending the message. Instead just try to send the data and if it // fails queue it to be sent when the connection is re-established. session.sendMessage(message, replyHandler: { (response) -> Void in // iOS app got the message successfully }, errorHandler: { (error) -> Void in // iOS app failed to get message. Send it in the background session.transferUserInfo(message) }) }
Then, in your iOS app:
// Do this here so it is setup as early as possible so // we don't miss any delegate method calls func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { self.watchKitSetup() return true } func watchKitSetup() { // Stop if watch connectivity is not supported (such as on iPad) if (WCSession.isSupported()) { let session = WCSession.defaultSession() session.delegate = self session.activateSession() } } func session(session: WCSession, didReceiveMessage message: [String : AnyObject], replyHandler: ([String : AnyObject]) -> Void) { // Handle the message from the apple watch... dispatch_async(dispatch_get_main_queue()) { // Update UI on the main thread if necessary } } func session(session: WCSession, didReceiveUserInfo userInfo: [String : AnyObject]) { // Handle the message from the apple watch... dispatch_async(dispatch_get_main_queue()) { // Update UI on the main thread if necessary } }
相关问答
更多-
这是我所做的: 将您的WatchOS1文件保存在备份文件夹中 删除所有WatchOS1目标和文件 添加新的WatchOS2目标(确保它编译) 将备份文件复制到新目标 Here is what I did: Save your WatchOS1 files in a backup folder Remove all WatchOS1 targets and files Add new WatchOS2 targets (make sure it compiles) Copy the backup files ...
-
您不能在watchOS 2上使用Parse SDK for iOS,因为它的代码在Apple Watch设备上运行。 文档: 在watchOS 2中,扩展程序在用户的Apple Watch上运行,而不是在用户的iPhone上运行,就像watchOS 1中的情况一样。 只需在iOS应用程序中实现您的代码,并通过WCSession类在iOS和watchOS2之间进行通信。 我这样做了 You can't use Parse SDK for iOS on watchOS 2, because its code r ...
-
有两种方法可以将使用podfile的Pod与WathOS集成。 1)直接添加必需的窗格以观看扩展名,如下所示。 target '
' do platform :watchos, '2.0' pod 'RealmSwift' pod 'Alamofire' pod 'MMWormhole', '~> 2.0.0' end 2)创建共享窗格,并添加到观看扩展和iOS目标。 def sharedPods pod 'RealmSwift' ... -
是否有可能从watchOS 3应用程序中唤醒iPhone应用程序?(Is it possible to wake up iPhone app from watchOS 3 app?)[2023-07-12]
Apple建议使用以下代码: - (void)session:(WCSession *)session activationDidCompleteWithState:(WCSessionActivationState)activationState error:(NSError *)error { if ([WCSession isSupported]) { WCSession* session = [WCSession defaultSession]; if (se ... -
如果没有其他工作,我建议创建一个新的Xcode项目(文件 - >新建 - >项目)。 然后导航到watchOS部分并选择带有WatchKit App的iOS应用程序。 从那里开始,您需要将旧项目中的代码复制并粘贴到新项目中。 这里有更多相关信息。 If nothing else works I would recommend creating a new Xcode Project (File -> New -> Project). Then navigate to the watchOS section ...
-
NSUserDefaults之间的NSUserDefaults NSUserDefaults是任何设备上的内存单元,因此它在iOS和watchOS以及tvOS等方面完全不同。 例如,如果您运行的代码在iOS上向NSUserDefaults添加了一个名为“key1”的新密钥(假设您使用的是NSUserDefaults.standardUserDefaults() ),那么当您请求在watchOS上读取其数据时,它会为您提供一个空字典。 这是因为它是第一次将字典仅存储在iOS App Target中,而不是存储 ...
-
可达意味着苹果手表和iPhone通过蓝牙或WiFi连接。 这并不意味着iPhone应用程序正在运行。 如果可以访问,那么当您尝试从Apple Watch发送消息时,它会在后台启动iPhone应用程序。 您需要尽快分配WKSession委托,因为委托方法(sendMessage)很快就会触发。 我想你要说的是如果可以的话调用sendMessage,而不是使用transferUserInfo方法。 要做到这一点,首先在你的苹果手表上: func applicationDidFinishLaunching() { ...
-
根据Apple的说法 : 在WatchOS模拟器上阻止CloudKit使用。 即使您通过配对的iOS模拟器登录,运行任何测试都会抛出“未经过身份验证”错误。 解决方法:在配对watchOS 3和iOS 10的配对设备上使用CloudKit。 这是来自watchOS 3发行说明,但似乎还没有修复。 只需在真正的手表上测试,一切都会正常工作。 According to Apple: CloudKit usage is blocked on watchOS Simulators. Running any test ...
-
您可以使用NSUserDefaults在本地存储数据。 要在Apple Watch和iPhone之间共享数据,您应该使用WatchConnectivity。 正如您在评论中所说的那样,还有另一个关于NSUserDefaults的问答。 You can use NSUserDefaults to store data locally. To share your data between Apple Watch and iPhone, you should use WatchConnectivity. As ...
-
WatchConnectivity 首先,两个应该相互通信的类(iOS和watchOS)需要符合
和#import WatchConnectivity框架 在发送数据之前,您需要检查您的设备是否能够发送数据 if ([WCSession isSupported]) { WCSession *session = [WCSession defaultSession]; session.delegate = self; [session ac ...