不知道为什么这个基本的watchOS 2应用程序无法正常工作

时间:2015-08-08 13:38:45

标签: swift watchkit apple-watch watch-os-2 wkinterfacelabel

这是我学习如何编码的第一天。我想使用watchOS 2制作一个简单的WatchKit应用程序。

我启动并运行了Hello World应用程序,现在当我尝试按下菜单时触发标签更改,代码将无法编译,并出现以下错误:

  

WKInterfaceLabel没有名为set的成员。

您可以看到详细图片here

Swift Code:

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!")
    }
}

1 个答案:

答案 0 :(得分:3)

Label.set()是问题所在。

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

相关问题