小编Kam*_*iel的帖子

在iOS13上向场景添加新的UIWindow

当应用程序进入前台时,我将添加新的UIWindow以显示密码视图控制器。

在iOS 13之前的AppDelegate中,我拥有属性var passcodeWindow = UIWindow(frame: UIScreen.main.bounds),其中我rootViewController是密码视图控制器,并且在applicationWillEnterForeground方法中将passcodeWindow.makeKeyAndVisible()其放置在顶部。

现在,当我想在iOS 13中实现密码功能时,这种方法就会出现问题。我将其移至sceneWillEnterForegroundSceneDelegate中的方法,但似乎无法passcodeWindow在此场景的实际窗口顶部显示。

我执行的操作与AppDelegate中的操作完全相同,并且passcodeWindow未显示。

sceneWillEnterForeground在AppDelegate和SceneDelegate中执行的方式:

passcodeWindow.rootViewController = passcodeViewController(type: .unlock)
passcodeWindow.makeKeyAndVisible()
Run Code Online (Sandbox Code Playgroud)

我希望passcodeWindow显示在场景中当前窗口的顶部。

xcode ios swift ios13

5
推荐指数
1
解决办法
1401
查看次数

标签 统计

ios ×1

ios13 ×1

swift ×1

xcode ×1