Reputation: 27050
I've facing an issue of push & pop my UIViewController. I've two UIViewControllers say A
& B
.
I have written an IBAction
in which I pushing to B
from A
like,
B *bView=[[B alloc] initWithNibName:@"B" bundle:nil];
[UIView beginAnimations:@"animation" context:nil];
[UIView setAnimationDuration:0.7];
[self.navigationController pushViewController:bView animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[bView release]; //Problem is here, If I comment this line, it works fine! else it crashes after my some transitions from A [push] B, B [pop] A.
Now in B
I've written an IBAction
to pop to A
like below
[UIView beginAnimations:@"animation" context:nil];
[UIView setAnimationDuration:0.7];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];
I have also calling [super dealloc]
from B
-(void) dealloc
{
[super dealloc];
}
If I don't release bView
it will not call dealloc, and may creates issues of memory.
Is this problem because of animation I applying?
I tried with all other ways like autorelease
, set bView=nil;
etc. but those won't work for me!
Any help, suggestion!
Upvotes: 0
Views: 601
Reputation: 59669
Try releasing bView
inside the animation completion block instead.
You can use old style + setAnimationDidStopSelector:
or if you don't need to support pre iOS4 devices, you can use animation blocks animateWithDuration:delay:options:animations:completion:
Upvotes: 1