我刚开始在Xcode中使用swift3,以便利用Apple.inc提供的ResearchKit。 虽然我已经使用Swift的Researchkit教程中的教程: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)
}
}
答案 0 :(得分:0)
你错过了添加代表。将ORKTaskViewControllerDelegate
添加到ViewController
class ViewController: UIViewController,ORKTaskViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad(
}
}