gpt4 book ai didi

ios - 如何在 ResearchKit 上创建个人同意页面?

转载 作者:搜寻专家 更新时间:2023-11-01 07:28:51 26 4
gpt4 key购买 nike

我在 Swift 上使用 Xcode 7.1.1 编码和 ResearchKit for iPhone iOS 9.1。我正在尝试创建同意页面,并一直在网上寻找示例,但没有成功。

来自 http://www.raywenderlich.com/104575/researchkit-tutorial-with-swift ,我已经得到了代码:

import Foundation
import ResearchKit

public var ConsentDocument:ORKConsentDocument {

let consentDocument=ORKConsentDocument()
consentDocument.title = "Consent"

//Consent Sections
let consentSectionTypes: [ORKConsentSectionType] = [
.Overview,
.DataGathering,
.Privacy,
.DataUse,
.TimeCommitment,
.StudySurvey,
.StudyTasks,
.Withdrawing
]
let consentSections: [ORKConsentSection] = consentSectionTypes.map { contentSectionType in
let consentSection = ORKConsentSection(type: contentSectionType)

consentSection.summary = "If you wish to complete this study..."
consentSection.content = "In this study you will only be asked 10 easy question!!!"
return consentSection
}


consentDocument.sections = consentSections

// Getting Signature
consentDocument.addSignature(ORKConsentSignature(forPersonWithTitle: nil, dateFormatString: nil, identifier: "ConsentDocumentParticipantSignature"))

return consentDocument
}

问题是,此代码创建的每个页面都具有相同的摘要和内容。如何为每个单独的部分制作单独的页面?

最佳答案

按照 Yuan 的建议,按如下方式替换您的 map 功能:

 let consentSections: [ORKConsentSection] = consentSectionTypes.map { contentSectionType in
let consentSection = ORKConsentSection(type: contentSectionType)
switch contentSectionType {
case .Overview:
consentSection.summary = "Overview"
consentSection.content = "Overview - Content"
case .DataGathering:
consentSection.summary = "DataGathering"
consentSection.content = "DataGathering - Content"
case .Privacy:
consentSection.summary = "Privacy"
consentSection.content = "Privacy - Content"
case .DataUse:
consentSection.summary = "DataUse"
consentSection.content = "DataUse - Content"
case .TimeCommitment:
consentSection.summary = "TimeCommitment"
consentSection.content = "TimeCommitment - Content"
case .StudySurvey:
consentSection.summary = "StudySurvey"
consentSection.content = "StudySurvey - Content"
case .StudyTasks:
consentSection.summary = "StudyTasks"
consentSection.content = "StudyTasks - Content"
case .Withdrawing:
consentSection.summary = "Withdrawing"
consentSection.content = "Withdrawing - Content"
default:
break
}
return consentSection
}

关于ios - 如何在 ResearchKit 上创建个人同意页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33966068/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com