【发布时间】:2023-02-21 04:36:40
【问题描述】:
我正在尝试使用 qualtrics 制作一个简单的 swiftui 应用程序,并且我正在尝试使用 uiviewrepresentable 来使其工作
@main
struct QualtricsPocApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
init() {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
// i have the actual intercept id's here i just removed them
Qualtrics.shared.initializeProject(brandId: "brand", projectId: "proj", extRefId: "ref", completion: { (myInitializationResult) in print(myInitializationResult);})
return true
}
}
}
struct QualtricsViewRep: UIViewControllerRepresentable {
typealias UIViewControllerType = UIViewController
func makeUIViewController(context: Context) -> UIViewController {
let vc = UIViewController()
Qualtrics.shared.evaluateProject { (targetingResults) in
for (interceptID, result) in targetingResults {
if result.passed() {
let displayed = Qualtrics.shared.display(viewController: self, autoCloseSurvey: true)
}
}
}
}
在让显示 = ... 我不断收到错误“无法将‘QualtricsViewRep’类型的值转换为预期的参数类型‘UIViewController’”,如何将此代码作为 UIViewController 返回以在 swiftui 应用程序中使用,或者是否有一些其他方式我应该接近这个?
【问题讨论】:
标签: ios swift swiftui uikit qualtrics