我不能得到didReceiveApplicationContext
被稱爲。有任何想法嗎?WatchKit didReceiveApplicationContext未被調用
InterfaceController
:
import WatchKit
import Foundation
import WatchConnectivity
class InterfaceController: WKInterfaceController, WCSessionDelegate {
@IBOutlet var colorLabel: WKInterfaceLabel!
private let session: WCSession? = WCSession.isSupported() ? WCSession.defaultSession() : nil
override init() {
super.init()
session?.delegate = self
session?.activateSession()
}
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
}
func session(session: WCSession, didReceiveApplicationContext applicationContext: [String : AnyObject]){
let colors : String = applicationContext["color"] as! String
colorLabel.setText(colors)
NSLog("session did receive application context")
}
}
我一直在學習本教程如下:http://www.kristinathai.com/watchos-2-how-to-communicate-between-devices-using-watch-connectivity/
的colorLabel
沒有NSLog
或設置情況。不知道我錯過了什麼。謝謝!
你可以發送發送端的代碼嗎?發送方的任何錯誤是否會返回? – ccjensen
正在返回的發送方沒有錯誤。如果你讓我知道你需要它,我仍然可以發佈代碼,但發送方都很好。如果是這樣,請告訴我。謝謝! – SRMR