在全屏模式下以Swiftui的形式展示模式,并防止关闭它

发布于 2025-01-20 07:01:49 字数 1001 浏览 1 评论 0原文

我有一个 SplashView,它充当起始视图并以模式打开游戏屏幕。

我只是尝试在 iPad 而不是 iPhone 上打开游戏,但视图看起来很奇怪。

当我切换到游戏屏幕时,屏幕显示为中间的小屏幕,我可以将其滑出以将其关闭。逻辑中的其他屏幕堆叠在该屏幕上。

如何防止堆叠并使所有屏幕全屏,类似于我在 iPhone 上打开它并防止通过滑动移动它们?

示例起始屏幕上有 2 个堆叠屏幕

  .sheet(isPresented: $isPlayerDashboardModal) {
                if let playerState = PlayerViewModel.createNewGameData(name: playerName) {
                    let playerViewModel = PlayerViewModel(player: playerState)
                    CityView(viewModel: playerViewModel)
                }
            }.frame(minWidth: DeviceTypes.ScreenSize.width, idealWidth: DeviceTypes.ScreenSize.width, maxWidth: DeviceTypes.ScreenSize.width, minHeight: DeviceTypes.ScreenSize.height, idealHeight: DeviceTypes.ScreenSize.height, maxHeight: DeviceTypes.ScreenSize.height, alignment: .center)
            

我已经将框架设置为最大,但这似乎没有做任何事情。

I have a SplashView that acts as a starting view and opens the game screen in modals.

I just tried to open the game in an iPad instead of iPhone and the views look all weird.

When I switch to the game screen the screen is presented as a small screen in the middle and I can swipe it out to close it. Other screens from the logic are stacked on this screen.

How can I prevent the stacking and have all screen in full screen, similar to when I open it on an iPhone and prevent moving them by swiping?

example of 2 stacked screens on the starting screen

  .sheet(isPresented: $isPlayerDashboardModal) {
                if let playerState = PlayerViewModel.createNewGameData(name: playerName) {
                    let playerViewModel = PlayerViewModel(player: playerState)
                    CityView(viewModel: playerViewModel)
                }
            }.frame(minWidth: DeviceTypes.ScreenSize.width, idealWidth: DeviceTypes.ScreenSize.width, maxWidth: DeviceTypes.ScreenSize.width, minHeight: DeviceTypes.ScreenSize.height, idealHeight: DeviceTypes.ScreenSize.height, maxHeight: DeviceTypes.ScreenSize.height, alignment: .center)
            

I set the frame to max already, but this does not seem to do anything.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沫离伤花 2025-01-27 07:01:49

将 .sheet 替换为 .fullScreenCover 以确保窗口全屏且无法通过下拉关闭。
要隐藏 iPad 上的状态栏,请在最终视图关闭之前添加: .statusBar(hidden: true) 。

replace .sheet with .fullScreenCover to ensure that window is full screen and cannot be closed via pulling it down.
To hide the statusbar on iPad include: .statusBar(hidden: true) before the final view closure.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文