1

这是我想要做的:使用来自ConsentDocument的结果,使用步骤标识符在 ViewController 中查看它。但签名始终为零。那么,我怎样才能从同意文件中获得名字和姓氏呢?

override func viewDidLoad() {
    super.viewDidLoad()
 let signatureResult = ORKConsentSignatureResult(identifier: "ConsentReviewStep")
        let signature = signatureResult.signature

        let label = UILabel(frame: CGRectMake(0, 0, 200, 21))
        label.center = CGPointMake(160, 284)
        label.textAlignment = NSTextAlignment.Center
        label.text = signature?.givenName
self.view.addSubview(label)}

在这里,我正在创建步骤,其中用户给了我 givenName(名字)和 familyName(姓氏)。此步骤名为reviewConsentStep

@IBAction func joinButtonTapped(sender: UIButton) {
    let consentDocument = ConsentDocument()
    let consentStep = ORKVisualConsentStep(identifier: "VisualConsentStep", document: consentDocument)

    let healthDataStep = HealthDataStep(identifier: "Health")

    let signature = consentDocument.signatures!.first!

    let reviewConsentStep = ORKConsentReviewStep(identifier: "ConsentReviewStep", signature: signature, inDocument: consentDocument)

    reviewConsentStep.text = "Review the consent form."
    reviewConsentStep.reasonForConsent = "Consent to join the Developer Health Research Study."

    let passcodeStep = ORKPasscodeStep(identifier: "Passcode")
    passcodeStep.text = "Now you will create a passcode to identify yourself to the app and protect access to information you've entered."

    let completionStep = ORKCompletionStep(identifier: "CompletionStep")
    completionStep.title = "Welcome aboard."
    completionStep.text = "Thank you for joining this study."

    let orderedTask = ORKOrderedTask(identifier: "Join", steps: [consentStep, reviewConsentStep, healthDataStep, passcodeStep, completionStep])
    let taskViewController = ORKTaskViewController(task: orderedTask, taskRunUUID: nil)
    taskViewController.delegate = self

    presentViewController(taskViewController, animated: true, completion: nil)
}

}

4

0 回答 0