我正在关注 swift ( http://www.raywenderlich.com/104575/researchkit-tutorial-with-swift ) 中的 ResearchKit 教程,但我无法将任何一种 IBaction 方法连接到主情节提要中的按钮。这是代码(来自教程):
import ResearchKit
class ViewController: UIViewController {
@IBAction func consentTapped(sender : AnyObject) {
let taskViewController = ORKTaskViewController(task: ConsentTask, taskRunUUID: nil)
taskViewController.delegate = self
presentViewController(taskViewController, animated: true, completion: nil)
}
@IBAction func surveyTapped(sender : AnyObject) {
let taskViewController = ORKTaskViewController(task: SurveyTask, taskRunUUID: nil)
taskViewController.delegate = self
presentViewController(taskViewController, animated: true, completion: nil)
}
}
extension ViewController : ORKTaskViewControllerDelegate {
func taskViewController(taskViewController: ORKTaskViewController, didFinishWithReason reason: ORKTaskViewControllerFinishReason, error: NSError?) {
taskViewController.dismissViewControllerAnimated(true, completion: nil)
}
}
我进入主情节提要并单击 View Controller,我尝试将我的类设置为 ViewController 和 UIViewController,并且这些方法应该显示在 Sent Events 中,但它们没有。我也尝试过 ctrl 拖动,但这对我也不起作用。