代码之家  ›  专栏  ›  技术社区  ›  owen gerig

手表按钮按下撞车

  •  0
  • owen gerig  · 技术社区  · 6 年前

    这似乎是相同的错误和条件 this unanswered SO question ,但我还有更多要添加的内容(很容易复制)

    在最新Xcode中创建新项目

    带WatchKit应用程序的iOS应用程序

    转到watchkit app>interface.storyboard并在接口控制器上放置一个按钮scene>interface controller enter image description here

    转到watchkit extension>interfaceController.swift并添加新成员

    @IBOutlet var scheduleMeetingButton: WKInterfaceButton!
    

    和方法

    @IBAction func scheduleMeeting(_ sender: Any) { }
    

    然后返回interface.storyboard并将这两个链接到按钮

    启动应用程序(在手表模拟器上) enter image description here

    然后单击按钮,您将得到这个执行错误

    enter image description here

    是什么导致了这个错误?

    1 回复  |  直到 6 年前
        1
  •  1
  •   paul590    6 年前

    从您的代码来看,我建议您从sender:any更新action函数到sender:wkInterfaceButton希望这有帮助!