I was able to figure out how to present the survey, however, now the survey does not dismiss.
I had to make another swift file which connects the ORKTaskViewController.
import SwiftUI
import ResearchKit
struct SurveyView: UIViewControllerRepresentable{
func makeUIViewController(context: Context) -> ORKTaskViewController{
let config = ORKTaskViewController(task: SurveyTask.surveyTask, taskRun: nil)
return config
}
func updateUIViewController(_ uiVIewController: ORKTaskViewController, context: Context){
}
typealias UIViewControllerType = ORKTaskViewController
}
Adding this line to the home screen SwiftUI
@State private var showingSurvey = false.
Making showingSurvey=true as the action to the button click,
with this at the end of the VBox to present the survey.
.sheet(isPresented: $showingSurvey){SurveyView()}
If anyone knows how to get the survey to dismiss, please reply.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: