addsubview animation works only first time

Posted by Priya on Stack Overflow See other posts from Stack Overflow or by Priya
Published on 2012-11-17T10:05:54Z Indexed on 2012/11/17 11:02 UTC
Read the original article Hit count: 193

I am trying add subview with animation effect using the code which work fine for the first time below.

CATransition *transition = [CATransition animation];
transition.duration = 1.0;
transition.type = kCATransitionMoveIn; 
transition.subtype = kCATransitionFromRight;

[newView.layer removeAllAnimations]
[newView.layer addAnimation:transition forKey:nil];
[self.masterview addSubview:newView];

There is a back button in newView which removes the View from the superview.

[newView removeFromSuperview];

Now when I try adding newView as subview again using the above code,its first adds the view as a subview(without animation) and again with animation.

© Stack Overflow or respective owner

Related posts about ios

Related posts about uiview