美文网首页
iOS 需要在viewWillDisappear执行的操作

iOS 需要在viewWillDisappear执行的操作

作者: iOS程序媛ing | 来源:发表于2021-11-18 10:55 被阅读0次

需要在viewWillDisappear执行的操作
(1)移除通知

[self.contentScrollView removeObserver:self forKeyPath:@"contentOffset"];

(2)移除观察者

[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];

(3)销毁timer

[self.timer invalidate];
self.timer = nil;

(4)停止定位

 [self.locationManager stopUpdatingLocation];

(5)webview移除注册的js方法

 [self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"locateAction"];

相关文章

网友评论

      本文标题:iOS 需要在viewWillDisappear执行的操作

      本文链接:https://www.haomeiwen.com/subject/juedtrtx.html