我正在使用Xcode 7.1.1编码与Swift上的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
}
问题是,此代码会创建具有相同摘要和内容的每个页面。如何为每个部分创建单独的页面?
答案 0 :(得分:2)
如袁建议更换你的地图功能如下:
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
}