I've created a UIViewControllerRepresentable
wrapper for the IASKAppSettingsViewController
so I can use it with my SwiftUI Project.
It worked fine for a Toggle Switch but when I attempted a PSMultiValueSpecifier
, my view did not transition to the screen with the multiple values.
Below is my wrapper:
import SwiftUI
import UIKit
import InAppSettingsKit
struct SettingsView: UIViewControllerRepresentable {
typealias UIViewControllerType = IASKAppSettingsViewController
func makeUIViewController(context: UIViewControllerRepresentableContext<SettingsView>) -> IASKAppSettingsViewController {
return IASKAppSettingsViewController()
}
func updateUIViewController(_ uiViewController: IASKAppSettingsViewController, context: UIViewControllerRepresentableContext<SettingsView>) {
}
}
This is the configuration (from the sample app) that is not working:
<dict>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>Title</key>
<string>Multi Value with a long title</string>
<key>Key</key>
<string>multivalue_long</string>
<key>DefaultValue</key>
<integer>2</integer>
<key>Values</key>
<array>
<integer>1</integer>
<integer>2</integer>
<integer>3</integer>
</array>
<key>Titles</key>
<array>
<string>One</string>
<string>Two</string>
<string>Three</string>
</array>
</dict>
Note: I didn't see any errors, just tapping on the screen did not transition to allow me to select values.
I found the issue:
The SettingsView
needed to be wrapped in a NavigationView
like the below:
NavigationView { SettingsView() }
This fixed the issue where the multiple values screen wasn't showing up.