3
votes

My app is View based application. I got 3 viewcontrollers. (main,sub,detail) each viewcontroller has one UIView. in MainViewcontroller, there's a button to launch subView. the method is as below.

-(IBAction) LaunchSubView: (id)sender {

subViewcontroller *viewController = [[subViewcontroller alloc] init];

UIView *currentView = self.view;
[UIView transitionFromView:currentView 
                    toView:viewController.view 
                  duration:0.5 
                   options:UIViewAnimationOptionTransitionFlipFromLeft   
                completion:^(BOOL finished){}];

}

While i try build and analyze, I got this warning. Potential leak of an object allocated on line 54 and stored into 'viewController' i tried [viewController release] after transitionFromView method and subViewcontroller *viewController = [[[subViewcontroller alloc] init] autorelease]; both ways cause the app crash. any idea what am i suppose to do? thanks in advance for any kind help. =)

2
What version of Xcode are you running? I tried to reproduce the problem without success.Matt Bierner
hi.. i'm running Version 3.2.5moon

2 Answers

1
votes

transitionFromView:toView:duration:options:completion: is not the right method to use. You should probably be using presentModalViewController:animated:.

If you read the documentation for transitionFromView:toView:duration:options:completion: it explains:

This method modifies the views in their view hierarchy only. It does not modify your application’s view controllers in any way. For example, if you use this method to change the root view displayed by a view controller, it is your responsibility to update the view controller appropriately to handle the change."

0
votes

try using

subViewcontroller *viewController = [[subViewcontroller alloc] initWithNibName:@"name of you nib file" bundle:@"if you have a bundle otherwise nil"]

and also release the viewController object before the end of the method like this

[subViewcontroller release];