Post

Replies

Boosts

Views

Activity

Presenting ResearchKit Survey from SwiftUI View
I am trying to present my ResearchKit Survey from a SwiftUI view. Before I moved my home screen to a SwiftUI view, I would present my survey using: let taskViewController = ORKTaskViewController(task: SurveyTask.surveyTask, taskRun: nil) taskViewController.delegate = self present(taskViewController, animated: true, completion: nil) I was able to present the SwiftUI from a UIKit view controller using: let mainHomeScreenSwUI = UIHostingController(rootView: MainHomeScreen()) mainHomeScreenSwUI.modalPresentationStyle = .fullScreen present(mainHomeScreenSwUI, animated: true, completion: nil) but now I would like to present my taskViewController from my SwiftUI view. I would like to open the survey from the press of a button like below. Button("Take Survey \(recentFriday ?? "01/01")") {               //open survey               let taskViewController = ORKTaskViewController(task: SurveyTask.surveyTask, taskRun: nil)               taskViewController.delegate = self               present(taskViewController, animated: true, completion: nil)             } This causes an error. Any help would be greatly appreciated!
1
0
1.5k
Feb ’23
Presenting ResearchKit Survey from SwiftUI View
I am trying to present my ResearchKit Survey from a SwiftUI view. Before I moved my home screen to a SwiftUI view, I would present my survey using: let taskViewController = ORKTaskViewController(task: SurveyTask.surveyTask, taskRun: nil) taskViewController.delegate = self present(taskViewController, animated: true, completion: nil) I was able to present the SwiftUI from a UIKit view controller using: let mainHomeScreenSwUI = UIHostingController(rootView: MainHomeScreen()) mainHomeScreenSwUI.modalPresentationStyle = .fullScreen present(mainHomeScreenSwUI, animated: true, completion: nil) but now I would like to present my taskViewController from my SwiftUI view. I would like to open the survey from the press of a button like below. Button("Take Survey \(recentFriday ?? "01/01")") {               //open survey               let taskViewController = ORKTaskViewController(task: SurveyTask.surveyTask, taskRun: nil)               taskViewController.delegate = self               present(taskViewController, animated: true, completion: nil)             } This causes an error. Any help would be greatly appreciated!
Replies
1
Boosts
0
Views
1.5k
Activity
Feb ’23