这是我学习编码的第一天。我想使用 watchOS 2 制作一个简单的 WatchKit 应用程序。
我启动并运行了 Hello World 应用程序,现在当我尝试让菜单按下触发标签进行更改时,代码将无法编译,并出现以下错误:
WKInterfaceLabel 没有名为 set 的成员。
你可以在这里看到详细的图像。
SWIFT代码:
import WatchKit
import Foundation
class InterfaceController: WKInterfaceController {
@IBOutlet var label: WKInterfaceLabel!
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
// Configure interface objects here.
}
override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
}
override func didDeactivate() {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
}
@IBAction func CookBabyCook() {
label.set("Cooked!")
}
}