[我在不使用故事板的情况下使用xcode创建了ios应用,但是我遇到了问题,我需要将显示器全屏显示,但无法正常工作

问题描述 投票:0回答:1

我目前正在使用xcode(Swift)创建应用程序,但我的大部分显示不是全屏显示,有些是全屏显示。到目前为止,我的项目包括四个查看器控制器:

登录

注册

忘记密码

和家

[当我启动该应用程序时,您可以登录并进入主屏幕并进入您的帐户(我设法全屏显示),但是,当启动该应用程序且未登录用户时,系统会向您显示使用两个按钮登录页面:

“没有帐户?注册”->进入注册表格

““忘记密码”->进入带密码的表单

这两个按钮在启动应用程序时不起作用,但是当用户登录到帐户并注销并取回登录后,上面的两个按钮现在起作用。我不确定为什么会这样,也不确定如何解决此问题,有人可以帮忙吗?

这是允许您切换到不同控制器的代码:

从登录表单到注册表单

let signUpButton: UIButton = {
    let button = UIButton(type: .system)
    button.setTitle("Don't have an account? Sign up", for: .normal)
    button.setTitleColor(UIColor(red: 170/255, green: 170/255, blue: 170/255, alpha: 1), for: .normal)
    button.addTarget(self, action: #selector(handleShowSignUp), for: .touchUpInside)
    return button
}()

@objc func handleShowSignUp() {
      let signUpVC = SignUpVC()
        self.navigationController?.pushViewController(signUpVC, animated: true)
  }

从登录表单到忘记密码的表单:

let forgotPasswordButton: UIButton = {
    let button = UIButton(type: .system)
    button.setTitle("Forgot password?", for: .normal)
    button.setTitleColor(UIColor(red: 170/255, green: 170/255, blue: 170/255, alpha: 1), for: .normal)
    button.addTarget(self, action: #selector(forgotPassword), for: .touchUpInside)
    return button
}()

@objc func forgotPassword() {
    let forgotPassword = ForgotPasswordVC()
    self.navigationController?.pushViewController(forgotPassword, animated: true)

     }

回到我原来的问题,以上所有内容都是全屏显示,直到您从那里注销为止,所有内容都返回到新的卡片布局,在这里您可以在后台看到以前的视图,并且我尝试将这一行添加到所有控制器,但似乎无法正常工作:

logInVC.modalPresentationStyle = .fullScreen

(显然格式化为特定的查看器控制器)

我该如何解决?

除:之外,我没有向我的appdelegate文件添加任何内容:

FirebaseApp.configure()

我已将以下内容添加到我的场景代表:

       guard let mainScene = (scene as? UIWindowScene) else { return }
            window = UIWindow(windowScene: mainScene)
            let mainTabVC = MainTabVC()
            window?.rootViewController = UINavigationController(rootViewController: mainTabVC)
            window?.makeKeyAndVisible()
ios swift xcode uinavigationcontroller
1个回答
0
投票

使用

navController.modalPresentationStyle = .fullScreen

而不是

logInVC.modalPresentationStyle = .fullScreen

在显示navController之前写此代码。

希望对您有帮助

© www.soinside.com 2019 - 2024. All rights reserved.