UIView animations that interact poorly

I see what seems to be the interaction between the individual animations, and I am very grateful for any suggestions to eliminate this effect.

Basically: I have an iPhone app that includes an β€œa” button in the root view. Pressing "a" calls up the view on the controller stack of the navigation view with flip animation. The extended view has a button to display the view back to the root.

Main code:

- (IBAction)pushOneView{
TheAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight 
                    forView:delegate.navigationController.view cache:NO];
[delegate.navigationController 
            pushViewController:oneViewController animated:NO];
[UIView commitAnimations];

}

This seems like normal, and the animation is pretty smooth.

The root view also includes a preview ("panelView") and another button "b". panelView can display either of the other two sub-items - by pressing "b" swaps between these subzones, with rotation animations. Code:

-(IBAction)swapPanels{
UIViewController *coming;
UIViewController *going;
float rotation;

if (self.aPanel.view.superview == nil) {
    coming = aPanel;
    going = bPanel;
    rotation = 3.14;
}
else {
    coming = bPanel;
    going = aPanel;
    rotation = -3.14;
}

// First half of spin
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.25];
CGAffineTransform swirlTransform = CGAffineTransformMakeRotation(rotation);
panelView.transform = swirlTransform;
[panelView setAlpha:0.1];
[UIView commitAnimations];

// Finish spin
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.25];
CGAffineTransform secondTransform = 
                        CGAffineTransformRotate(swirlTransform, rotation);
panelView.transform = secondTransform;
[panelView setAlpha:1];
[UIView commitAnimations];

// Swap the panels
[going.view removeFromSuperview];
[panelView insertSubview:coming.view atIndex:0];

}

. .

, "a" , "b" . , , "a" , . "b" . "a" ... "a" , .

100% . , . - . "b" ( ), "a" "sw" "b" . , . "a" , "b" , , , , ( ).

, : . "a" , "b" - - , "b" . , ? ? ...?

.

+3
2

"b" . begin/commit, . "b" , , . , , , .

, :

[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(rotationAnimationFinished:finished:context:)];

'b' ( " " ). ,

- (void)rotationAnimationFinished:(NSString *)animationID finished:(BOOL)finished context:(void *)context;

, , , "b" ( "Finish spin" ).

, .

+8

, , : , - "b" , . , , transform View "b" ... , , , View.

, , , , "b" , View : CGAffineTransformIdentity:

  • (void) spinFinished: (NSString *) ID : (BOOL) : (void *) context { panelView.transform = CGAffineTransformIdentity; }

-'b ' ' a ', , . , , . .

+2

Source: https://habr.com/ru/post/1707985/


All Articles