I came here to ask for help because I'm on my way to finishing my iphone project and I want it to be perfect!
I have some issues with allocation and deallocation of a UIViewcontroller.
Let me explain :
I have a UITableview with custom cells. In each custom cells, a button that will allocate a new UIViewController : ListOfAGuestFriendViewController;
So, I've made a delegate which calls a method to make a "flip transition", and show my new ListOfAGuestFriendViewController view.
My problem is, and I've gotten the same problem with ALL of my addSubiew, that ListOfAGuestFriendViewController never get deallocated, or gets deallocated just after the view loads!
Can someone explain me exactly how I can make a perfect addSubview ?
Here's my code :
When i flip the view :
-(void)flipAView
{
Guest *currentSelectedGuest = [self createAGuestUsingIndexPath:self.selectedIndex];
ListOfAGuestFriendViewController *listOfAGuestFriendViewController = [[ListOfAGuestFriendViewController alloc]init];
[listOfAGuestFriendViewController setCurrentGuestSelected:currentSelectedGuest];
[listOfAGuestFriendViewController setMyListOfContactControllerDelegate:self];
[UIView animateWithDuration:0.25 animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:self.tableviewContainerView cache:YES];
[self.tableviewContainerView addSubview:listOfAGuestFriendViewController.view];
}completion:^(BOOL finished){
[listOfAGuestFriendViewController release];
[self collapseCurrentExpandedCell];
}];
}
When i want to go back :
-(IBAction)goBackButtonGotPressed:(id)sender{
[UIView animateWithDuration:0.5 animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:[self.view superview] cache:YES];
[self.view removeFromSuperview];
}];
}
If I remove that line of code :
[listOfAGuestFriendViewController release];
My listOfAGuestFriendViewController never deallocates.
I don't use properties for this instanciation, but when i do, it's the same!