UIPageViewController设置中的viewcontrollers是否需要发布?

时间:2012-02-05 12:33:04

标签: ios5 uipageviewcontroller

我正在使用Xcode的Apple UIPageViewController模板来创建交互式相册。一切正常,只要每当我翻页(创建一个新的viewcontroller)时,内存分配就会一直向上和向上,直到应用程序崩溃。在我看来,视图控制器永远不会被“释放”(我仍然允许在ARC环境中使用该词吗?)。它似乎与页面的内容没有任何关系,因为当我在...中注释掉所有内容创建内容时...每次我翻页时内存仍然不断上升,而不是像当一个大图像被包含但仍然继续爬行时。

这里有一个完全相同的问题:PageViewController: How to release ViewControllers added to it?但是这个问题涉及前弧和前弧。故事板情况。不允许添加自动释放,似乎编译器似乎没有处理它。 : - (

有什么建议吗?

2 个答案:

答案 0 :(得分:3)

问题证明是永远不够该死的“UIImage imagedNamed”构造。在我读到某个地方后,在最近的xcode版本中修复了这个问题,这可能是我自己的错。所以我假设图像不再被缓存,而事实恰恰相反。一旦我将所有内容更改为“UIImage imageWithContentsOfFile”,该应用程序就开始像婴儿一样平稳地工作。

答案 1 :(得分:0)

我在制作一张图片非常大的图片时遇到了同样的问题。我转到其他问题,你提供了一个链接,并为我解决了它。添加“autorelease”会释放内存。

UIPageviewcontroller委托方法“viewControllerAtIndex”中。我改变了:

// Create a new view controller and pass suitable data.
ContentViewController *contentViewController = [[ContentViewController alloc] initWithNibName:@"ContentViewController" bundle:nil];

并添加了自动释放

// Create a new view controller and pass suitable data.
ContentViewController *contentViewController = [[[ContentViewController alloc] initWithNibName:@"ContentViewController" bundle:nil] autorelease] ;

这不包含在苹果示例中,但我也在每页使用xib。我一直在使用仪器进行调试,并且看到内存立即被回收,并且在之前没有调用dealloc。

在这里找到答案.... https://stackoverflow.com/a/7934392/1212585

相关问题