0

这是我学习编码的第一天。我想使用 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!")
    }
}
4

1 回答 1

3

Label.set()是这里的问题。

我相信标签对象没有set()方法。您必须将其替换为setText().

于 2015-08-08T13:39:54.593 回答