I'm trying to make a very simple transition: one view moves half the screen to the left, and the second ("to") view moves half the screen.
My animation works, but when I change the animation, I see a flicker. The "to" view (i.e., the Original view) is displayed at the beginning of 0.0, although I am setting a different frame.
I dropped the view hierarchy. The frames are set correctly (-100 0; 320 480 for viewing), but nevertheless it is displayed at 0.0. Is a screenshot of a view cached somewhere for animation?
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext { UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; UIView *container = [transitionContext containerView]; CGRect offsetCoverRect = CGRectMake(-100.0, 0.0, 320, 480); CGRect detailsRect = CGRectMake(-100.0 + 320.0, 0.0, 320, 480); CGRect detailsOutsideRect = CGRectMake(320.0, 0.0, 320, 480); CGRect normalRect = CGRectMake(0.0, 0.0, 320, 480); if (self.revealDetails) { toViewController.view.frame = detailsOutsideRect; [container addSubview:toViewController.view]; } else { [container insertSubview:toViewController.view belowSubview:fromViewController.view];
Update:
This seems to be related to the UIModalPresentationCustom . I need to use this so that it is not removed from the view when the transition is completed. However, it seems that it is assumed that the view controller for the inverse transition starts at 0.0.
Update 2:
It is very easy to reproduce the following code:
UIView *snapshot = [containerView snapshotViewAfterScreenUpdates:NO]; [containerView addSubview:snapshot];
The above will be displayed on the screen in the center, regardless of what actual frame or center I set before the animation.
ios objective-c uiviewcontroller ios7 uiviewanimation
Mark
source share