简体   繁体   中英

Modal View doesn't release itself after dismiss

I've been facing a weird issue with dismissing a modal view.

I present a modal view like this:

 ResepiDetail *detail =(ResepiDetail*)[[ResepiDetail alloc]init];
 [self presentModalViewController:detail animated:YES]; 

and dismiss it like this with a back button:

[self dismissModalViewControllerAnimated:YES];

after this the view dismisses itself and goes back to the previous view, but it doesn't release itself from memory. I found it out by sending a notification message and that view received it. Additionally I tried to track the VM memory Allocation, and it seems the view is still in memory.

I'm using ARC and have the same method used for another view which works perfectly.

The code is fine, as posted, so here's some hints on how to proceed:

A sure fire way to be certain your view controller hasn't been deallocated is to override dealloc and log something identifiable. You can still do that in ARC, just don't explicitly call super . If you don't see the log when you expect to, then you have a problem.

Assuming that you have determined that you absolutely do have a problem, then the issue becomes finding the retain cycle. If the issue is that an instance of ResepiController isn't being dealloc'd, then you need to look for...

  1. Any code outside the ResepiController class that has a strong reference to it. For example, if your class signs up as the delegate of some other class, make sure the delegate isn't using a strong reference.
  2. Any internal blocks that may have implicitly retained self . Are there any blocks anywhere in your program that may have a reference to your controller at the time that you think it should be released?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM