关闭视图控制器时停止 webview
Stop uiwebview when close veiw controller
我正在 uiwebview 中加载声音云 url,当我关闭包含 webview 的屏幕时,声音仍在后台运行
谁能告诉我如何阻止它??
viewDidDissapear(animated: Bool) {
super.viewDidDissapear(animated)
webView.stopLoading()
}
编辑:根据评论,这适用于 OP
viewDidDissapear(animated: Bool) {
super.viewDidDissapear(animated)
webView.loadHTMLString("", baseURL: nil);
}
试试这个:
- (void)applicationDidEnterBackground:(UIApplication *)application {
NSError *activationError = nil;
BOOL success = [[AVAudioSession sharedInstance] setActive: NO error: &activationError];
if (!success) { /* handle the error in activationError */ }
}
不要忘记在您的 appDelegate 中导入框架 Class
我正在 uiwebview 中加载声音云 url,当我关闭包含 webview 的屏幕时,声音仍在后台运行
谁能告诉我如何阻止它??
viewDidDissapear(animated: Bool) {
super.viewDidDissapear(animated)
webView.stopLoading()
}
编辑:根据评论,这适用于 OP
viewDidDissapear(animated: Bool) {
super.viewDidDissapear(animated)
webView.loadHTMLString("", baseURL: nil);
}
试试这个:
- (void)applicationDidEnterBackground:(UIApplication *)application {
NSError *activationError = nil;
BOOL success = [[AVAudioSession sharedInstance] setActive: NO error: &activationError];
if (!success) { /* handle the error in activationError */ }
}
不要忘记在您的 appDelegate 中导入框架 Class