点击按钮时,我使用以下代码移动到另一个 View Controller 。
var window: UIWindow?
window = UIWindow.init(frame: UIScreen.main.bounds)
window?.autoresizesSubviews = true
window?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
let trackingViewController = LoginCameraViewController.init(screen:
.main)
window?.rootViewController = trackingViewController
window?.addSubview((trackingViewController?.view)!)
window?.makeKeyAndVisible()
window?.layoutSubviews()
每次单击按钮,都会向应用程序添加一个新窗口。我想删除添加的最新窗口。 使用以下代码可以知道应用程序中存在的窗口数。
let windowz = UIApplication.shared.windows
print("subviews",windowz)
最佳答案
我认为您对 iOS 中的导航概念有误。窗口就像一个根对象,其中出现了 ViewController。因此,您首先要寻找的解决方案可能是 UINavigationController
。
关于swift - 如何在 Swift 中从 UIApplication 中删除窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52097866/