【问题标题】:I got an error [Type "View Controller" does not conform to protocol "ORKTaskViewControllerDelegate"]我收到错误 [类型“视图控制器”不符合协议“ORKTaskViewControllerDelegate”]
【发布时间】:2017-06-21 02:53:06
【问题描述】:

我刚刚开始在 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)
  }
}

【问题讨论】:

    标签: researchkit swift3.2


    【解决方案1】:

    您错过了添加委托。将ORKTaskViewControllerDelegate添加到ViewController

    class ViewController: UIViewController,ORKTaskViewControllerDelegate {
       override func viewDidLoad() {
        super.viewDidLoad(
       }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多