How can I avoid leakage with this block-based animation sequence?

I am working on animating small routines in my user interface using a flip transition. To make the Flip transition work correctly, I create a temporary UIView to provide context, start the transition, and then you will need to clear it later. But it’s hard for me to figure out how to free an object without crashing the application. Here's the code block:

UIView *tempContainer = [UIView alloc];
tempContainer = [self.view viewWithTag:700];

[UIView transitionWithView:tempContainer
        duration:2
        options:UIViewAnimationOptionTransitionFlipFromRight
        animations:^{ 
                    [[[tempContainer subviews] objectAtIndex:0] removeFromSuperview]; 
                    [tempContainer addSubview:newImageView];
                    [newImageView release];
                    } 
            completion:^(BOOL finished){
                    [tempContainer release]; //Crashes app
                    }];

iOS4. , tempContainer , , , [UIView transition...], . , ? ( 30 .)

+1
1

, +alloc -ed

UIView *tempContainer = [UIView alloc];

.

tempContainer = [self.view viewWithTag:700];

, -release, ([self.view viewWithTag:700]).

+1

All Articles