如果在前台运行应用程序时WKWebView终止,则将对其委托调用webViewWebContentProcessDidTerminate
。
但是,如果应用程序在后台会发生什么呢?
它还会立即收到回电吗?它会收到它,当应用程序是以后的前瞻?它一点也不运行吗?
我目前我也不知道如何触发终止-否则我会尝试它。
我之所以这样问,是因为我想让它重新加载被终止的web视图,以避免在我的应用程序中出现空白屏幕,但我不确定这是否真的适用于在后台运行的应用程序。
发布于 2022-09-05 12:57:25
如果您正在运行模拟器,您可以从命令行终止web内容进程以触发webViewWebContentProcessDidTerminate
调用:
# In the command line, find the PID of your simulator process:
ps -p `pgrep launchd_sim`
# or if you have many simulators running:
ps -A | grep launchd_sim
# Find the PID of the WebContent process:
pgrep -P <simulator-pid> 'com.apple.WebKit.WebContent'
# kill it
kill <webcontent-pid>
# or if you want a one-lner:
kill $(pgrep -P $(pgrep launchd_sim) 'com.apple.WebKit.WebContent')
要点:https://gist.github.com/jasonbekolay/dad7c446ae1b02f174dc3eb3a5ea70ee
发布于 2022-03-30 13:31:55
对我来说,只有当我的应用程序处于后台时,WKWebView才会终止,而iOS对于在我的应用程序中终止WKWebView的其他应用程序缺乏内存。如果你再次打开这个应用程序,WKWebView就坏了,webViewWebContentProcessDidTerminate
就会被调用。
尝试复制为@joemasilotti
https://stackoverflow.com/questions/71350041
复制相似问题