dobe
10/07/2024, 3:10 PMshouldAutorotate
and supportedInterfaceOrientations
when using androidx.compose.ui.window.ComposeUIViewController
?Andrei Salavei
10/07/2024, 6:55 PMComposeUIViewController
.dobe
10/08/2024, 6:05 AMAndrei Salavei
10/08/2024, 6:45 AMdobe
10/08/2024, 6:57 AMimport SwiftUI
import ComposeApp
@main
struct iOSApp: App {
init() {
KoinBootstrapperKt.doInitKoin()
}
var body: some Scene {
WindowGroup {
ContentView().preferredColorScheme(.dark)
}
}
}
and:
import UIKit
import SwiftUI
import ComposeApp
struct ComposeView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
MainViewControllerKt.MainViewController()
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}
struct ContentView: View {
var body: some View {
ComposeView().ignoresSafeArea()
}
}
my usecase is that i want to force the screen orientation dynamicallyAndrei Salavei
10/08/2024, 7:21 AMmy usecase is that i want to force the screen orientation dynamicallyOh, that's a bad idea on iOS... never worked as intended. But if you want to try it, it's here:
func makeUIViewController(context: Context) -> UIViewController {
ParentViewController(child: MainViewControllerKt.MainViewController())
}
And then:
class ParentViewController: UIViewController {
val child: UIViewController
init(child: UIViewController) {
self.child = child
}
func viewDidLoad() {
// Here does code from the article
}
// override var supportedInterfaceOrientations....
}
dobe
10/08/2024, 7:27 AM