QMUISearchController 在 active 时如果被强制切走则可能出现内存泄漏
MoLice opened this issue · comments
MoLice commented
重现操作
- 某个处于
UINavigationController
里的 VC 里使用QMUISearchController
。 - 在 VC 里点搜索框进入搜索。
- 此时对 VC 调用
[self.navigationController popToRootViewControllerAnimated:YES]
强制切走界面。 - 会发现 VC 和 VC 里的
QMUISearchController
均未被析构。
同样地,如果把上述的3换成 UIApplication.sharedApplication.delegate.window.rootViewController = UIViewController.new
也依然会导致4的现象。
但如果 VC 不处于 UINavigationController
里则没这个问题。
解决方式
应该是系统的 bug,但暂时没去深究,目前的解决方式是 hook - [UIViewController didMoveToParentViewController:]
发现离开界面时正在搜索状态则手动降下搜索。