在调用popViewControllerAnimated时ARC

在调用popViewControllerAnimated时ARC

本文介绍了为什么在调用popViewControllerAnimated时ARC不释放内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目使用ARC,并且当我必须使用导航控制器显示视图时,请执行以下操作:

my project use ARC, and when i have to show a view with navigation controller i do this:

ShareViewController_iPhone *share = [[ShareViewController_iPhone alloc] initWithNibName:@"ShareViewController_iPhone" bundle:nil];
[self.navigationController pushViewController:share animated:YES];

我可以在xcode中看到内存增加了某个值,然后当我关闭视图时,我这样做了:

and i can see in xcode that the memory is increased of a certain value, then when i dismiss the view i do this:

[self.navigationController popViewControllerAnimated:YES];

但是当视图关闭时,内存不会减少,我该怎么办?

but when the view is closed, the memory doesn't decrease, how i can do it?

推荐答案

当您弹出ViewController且它不释放时,意味着在控制器中有一个参考循环.您必须检查代表是否有参考,阻止,弱参考,强参考.

When you pop a ViewController and it don't release, it means have a reference cycle in your controller. You must check delegate if have, block, weak, strong reference.

  • 您的代表必须是弱引用.
  • 如果使用块.自我必须是弱引用:__weak id weakSekf =自我;

希望这些信息对您有所帮助. :)

Hope these information will help you. :)

这篇关于为什么在调用popViewControllerAnimated时ARC不释放内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 07:42