我正在使用这个SO答案提供的技术在SFSafariViewController中预加载一些URL,如下所示:
addChildViewController(svc)
svc.didMoveToParentViewController(self)
view.addSubview(svc.view)
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下代码删除Safari View控制器:
svc.willMoveToParentViewController(nil)
svc.view.removeFromSuperview()
svc.removeFromParentViewController()
Run Code Online (Sandbox Code Playgroud)
现在我可以预加载URL并毫无问题地显示Safari视图.但是,在我重复该过程(预加载/显示/删除)几次(可能超过30次)后,应用程序将因某些内存问题而崩溃,因为日志显示Memory level is not normal or this app was killed by jetsam应用程序崩溃的时间.
在崩溃之前,我看到了一些关于可能泄漏警告的日志:
<Warning>: notify name "UIKeyboardSpringBoardKeyboardShow" has been registered 20 times - this may be a leak
<Warning>: notify name "com.apple.SafariViewService-com.apple.uikit.viewService.connectionRequest" has been registered 20 times - this may be a leak
Run Code Online (Sandbox Code Playgroud)
我在删除Safari View控制器时是否正确执行此操作?我错过了什么吗?或任何解决此问题的建议?