我正在使用这个SO答案提供的技术来像这样预加载一些URL到SFSafariViewController中:
addChildViewController(svc)
svc.didMoveToParentViewController(self)
view.addSubview(svc.view)
我尝试使用以下代码移除Safari View控制器:
svc.willMoveToParentViewController(nil)
svc.view.removeFromSuperview()
svc.removeFromParentViewController()
现在我可以预加载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
我在移除 Safari 视图控制器时做得对吗?有什么我错过的东西吗?或者有什么建议可以解决这个问题吗?