简体   繁体   English

当 ViewController 被关闭时,本地创建的对象会被释放吗?

[英]Do locally created objects get released when their ViewController is dismissed?

I'm throwing up around 50 UIImageViews into a view via a loop, looks something like this (Photo is just my subclass):我通过循环将大约 50 个 UIImageViews 扔到一个视图中,看起来像这样(照片只是我的子类):

Photo *photoImage = [[Photo alloc] initWithImage:photo];
[self.view addSubview:photoImage];

My current design flow uses the presentViewController and dismissViewController to move along views.我当前的设计流程使用presentViewControllerdismissViewController来移动视图。 When this I decide to dismiss this view, are these objects removed from memory and cleaned up?当我决定驳回这个观点时,这些对象是否从 memory 中移除并清理干净? Also, are my array objects removed when the viewController is dismissed, or am I suppose to be using viewDidUnload?此外,当 viewController 被关闭时,我的数组对象是否被删除,或者我是否应该使用 viewDidUnload?

I'm using ARC btw.我正在使用 ARC 顺便说一句。 Thanks谢谢

use Autorelease使用自动释放

Photo *photoImage = [[Photo alloc] initWithImage:photo]Autorelease]; Photo *photoImage = [[Photo alloc] initWithImage:photo]Autorelease];

[self.view addSubview:photoImage]; [self.view addSubview:photoImage];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 取消关闭viewController时重新启动键盘 - Resign keyboard when viewController is dismissed 什么时候释放对象 - when are objects released 从另一个模态视图控制器调用时ABPeoplePicker崩溃,并且两者均被消除 - Crash in ABPeoplePicker when called from another modal viewcontroller and both dismissed 调用dismissViewControllerAnimated但不解除ViewController - dismissViewControllerAnimated is called but ViewController is not dismissed 释放包含这些对象的NSMutableArray时如何释放复合对象? - How composite objects are released when the NSMutableArray that contains those objects are released? iPhone SDK:对象被推下另一个viewController时丢失? - iphone sdk: objects get lost when another viewController is pushed? iOS - 在ARC下弹出时未释放ViewController - iOS - ViewController not being released when popped under ARC 当我使用.xib文件进行布局时,在释放视图控制器时不会释放我的viewController IBOutlets - When I use a .xib file to layout my viewController IBOutlets aren't being released when the view controller is released ARC和dismissModalViewControllerAnimated:不释放视图控制器内存 - ARC and dismissModalViewControllerAnimated : viewcontroller memory is NOT released 何时释放相关对象? - When does an associated object get released?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM