This is how I switch views in my app:
CGRect frame = self.view.frame;
frame.origin.x = CGRectGetMaxX(frame);
ViewController *view2 = [[[ViewController alloc] init] autorelease];
view2.view.frame = frame;
[self.view.superview addSubview:view2.view];
[UIView animateWithDuration:0.4
animations:^{
CGRect frame = self.view.frame;
view2.view.frame = frame;
frame.origin.x -= frame.size.width;
self.view.frame = frame;
}
completion:^(BOOL finished){
[self.view removeFromSuperview];
}];
The problem is, is that my dealloc is not getting called. Any ideas why and how can I fix this?
Thanks!
Is this code in a view controller (it looks like it is)? If so, it makes sense removing your view would not cause the view controller itself to be released – someone else is retaining that. It’s the same thing that happens during a memory warning when your view is unloaded, but not your view controller…
Basically, what dealloc are you expecting to be called?