Skip to content

Commit 3ce3585

Browse files
committed
[BUG] Interaction issue in Cube navigation solved
1 parent 9cbef5c commit 3ce3585

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

AnimationControllers/CECubeAnimationController.m

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ -(NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)tr
3939
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext fromVC:(UIViewController *)fromVC toVC:(UIViewController *)toVC fromView:(UIView *)fromView toView:(UIView *)toView
4040
{
4141

42+
//Calculate the direction
4243
int dir=0;
4344
switch (self.cubeAnimationType) {
4445
case CubeAnimationTypeNormal:
@@ -57,7 +58,8 @@ - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionCo
5758
CATransform3D viewToTransform;
5859

5960
//We create a content view for do the translate animation
60-
UIView *generalContentView = [[UIView alloc] initWithFrame:transitionContext.containerView.bounds];
61+
UIView *generalContentView = [transitionContext containerView];
62+
6163
switch (self.cubeAnimationWay) {
6264
case CubeAnimationWayHorizontal:
6365
viewFromTransform = CATransform3DMakeRotation(dir*ROTATION_ANGLE, 0.0, 1.0, 0.0);
@@ -89,15 +91,11 @@ - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionCo
8991
//Create the shadow
9092
UIView *fromShadow = [fromView addOpacityWithColor:[UIColor blackColor]];
9193
UIView *toShadow = [toView addOpacityWithColor:[UIColor blackColor]];
92-
9394
[fromShadow setAlpha:0.0];
9495
[toShadow setAlpha:1.0];
9596

97+
//Add the to- view
9698
[generalContentView addSubview:toView];
97-
[generalContentView addSubview:fromView];
98-
99-
// Add the toView to the container
100-
[[transitionContext containerView] addSubview:generalContentView];
10199

102100
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
103101
switch (self.cubeAnimationWay) {
@@ -119,9 +117,10 @@ - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionCo
119117
[fromShadow setAlpha:1.0];
120118
[toShadow setAlpha:0.0];
121119

122-
123120
}completion:^(BOOL finished) {
124121

122+
//Set the final position of every elements transformed
123+
[generalContentView setTransform:CGAffineTransformIdentity];
125124
fromView.layer.transform = CATransform3DIdentity;
126125
toView.layer.transform = CATransform3DIdentity;
127126
[fromView.layer setAnchorPoint:CGPointMake(0.5f, 0.5f)];
@@ -130,13 +129,6 @@ - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionCo
130129
[fromShadow removeFromSuperview];
131130
[toShadow removeFromSuperview];
132131

133-
[generalContentView removeFromSuperview];
134-
135-
//Relocated the views
136-
[[transitionContext containerView] addSubview:fromView];
137-
[[transitionContext containerView] addSubview:toView];
138-
[generalContentView removeFromSuperview];
139-
140132
if ([transitionContext transitionWasCancelled]) {
141133
[toView removeFromSuperview];
142134
} else {

0 commit comments

Comments
 (0)