Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subview fade in and fade out help

I am having a problem fading out my subview. I have no trouble fading the view in but fading out ..just drops the view.

-(void)flipToReview {
ReviewViewController *reviewVariable = [[ReviewViewController alloc] initWithNibName:@"ReviewViewController" bundle:nil];
[self setReviewViewController:reviewVariable];
self.ReviewViewController.view.alpha =0;
[UIView beginAnimations:@"flipview" context:nil]; 
[UIView setAnimationDuration:0.3];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:_window cache:YES];
[reviewVariable release];    
[self.window addSubview:self.ReviewViewController.view];
self.ReviewViewController.view.alpha =1;

[UIView commitAnimations];
}


-(void)flipBackFromReview {
//   self.ReviewViewController.view.alpha = 1;

[UIView beginAnimations:@"trip" context:nil]; 
[UIView setAnimationDuration:0.3];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];

[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:_window cache:NO];
self.ReviewViewController.view.alpha = 0;
[self.ReviewViewController.view removeFromSuperview];
[UIView commitAnimations];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
[self.ReviewViewController.view setHidden:1];
NSLog(@"remove subview"); 
}
like image 582
BlockReader Avatar asked Dec 21 '22 13:12

BlockReader


1 Answers

Try the following:

[UIView animateWithDuration:3.0 delay:0.0
                    options:UIViewAnimationOptionAllowUserInteraction
                 animations:^{ ReviewViewController.view.alpha = 0.0;}
                 completion:^(BOOL fin) {
                 if (fin) [ReviewViewController.view removeFromSuperview];
                 }];
like image 171
Julian Avatar answered Dec 26 '22 10:12

Julian