0

我刚刚开始在 Xcode 中使用 swift3,以便利用 Apple.inc 提供的 ResearchKit。虽然我已经完成了 Researchkit Tutorial with Swift: Getting started in Ray Wenderlich 的教程,但我在 ViewController 的扩展方面遇到了麻烦。以下是我的代码。

import ResearchKit
import UIKit

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
  }

  override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
  }

  @IBAction func consentTapped(sender : AnyObject) {
    let taskViewController = ORKTaskViewController(task: ConsentTask, taskRun: nil)
    taskViewController.delegate = self
    present(taskViewController, animated: true, completion: nil)
  }
}

extension ViewController: ORKTaskViewControllerDelegate {

  func taskViewController(taskViewController: ORKTaskViewController, didFinishWithReason
         reason: ORKTaskViewControllerFinishReason, error: NSError?) {
    //Handle results with taskViewController.result
    taskViewController.dismiss(animated:true, completion: nil)
  }
}
4

1 回答 1

0

您错过了添加委托。添加ORKTaskViewControllerDelegate到视图控制器

class ViewController: UIViewController,ORKTaskViewControllerDelegate {
   override func viewDidLoad() {
    super.viewDidLoad(
   }
}
于 2017-07-04T10:47:49.903 回答