为什么WKInterfacePicker被认为是未声明的类型?

时间:2015-07-10 05:03:26

标签: watch-os-2 wkinterfacecontroller

我正在使用Xcode Version 7.0 beta 3.尝试使用WKInterfacePicker时,出现错误。

这是我的WKInterfaceController的代码:

import WatchKit
import Foundation


class RBWelcomeVC: WKInterfaceController {

@IBOutlet var pickerAllWorkouts: WKInterfacePicker!


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()
}

}

注意我的IBOutlet。当我通过控制从故事板拖动创建它时。它创建了插座并立即将此错误带入其中:

 Use of undeclared type 'WKInterfacePicker'

由于这不起作用,我尝试手动创建插座。我打字:

 @IBOutlet var pickerAllWorkouts: WKInterfa...

当试图让Xcode完成自动完成时,我注意到WKInterfacePicker不是一个建议。挑选者不存在。这只是一个错误还是我做错了什么?

1 个答案:

答案 0 :(得分:7)

您应该检查RBWelcomeVC.swift文件的“目标成员资格”是否未包含在您的iOS应用程序中,它应该只在Apple Watch Extension上。这对我有用。

“目标会员”位于Xcode(AKA:Utilities)的侧栏

发布图片需要更多声望。

编辑:图片:http://imgur.com/rQ1xwtG

相关问题