Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[viewController.view removeFromSuperview] 这样移除不正确 #97

Open
GitHubWanglei opened this issue Jul 17, 2019 · 0 comments
Open

Comments

@GitHubWanglei
Copy link

以下源代码不够严谨:
[viewController willMoveToParentViewController:nil];
[viewController.view removeFromSuperview];
[viewController removeFromParentViewController];
如果需要重新setViewControllers时,会移除之前的控制器,如果之前的控制器view没有加载,移除时会先走viewDidLoad, 然后才移除,若viewDidLoad里面同步任务较多,造成卡顿等问题。

可改为:
[viewController willMoveToParentViewController:nil];
if (viewController.isViewLoaded) {//判断view是否已加载
[viewController.view removeFromSuperview];
}
[viewController removeFromParentViewController];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant