Вот мой текущий код
plought-override ».import SwiftUI
@main
struct testApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
//Main code here
}
}
}
< /code>
mainview.swift
import SwiftUI
struct ContentView: View {
var body: some View {
ZStack {
// rest of code is here
}
}.onAppear {
UIDevice.current.setValue(UIInterfaceOrientation.portrait.rawValue, forKey: "orientation") // Forcing the rotation to portrait
AppDelegate.orientationLock = .portrait // And making sure it stays that way
}
}
class AppDelegate: NSObject, UIApplicationDelegate {
static var orientationLock = UIInterfaceOrientationMask.all
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return AppDelegate.orientationLock
}
}
Подробнее здесь: https://stackoverflow.com/questions/788 ... -or-scened
Мобильная версия