Note that there are some explanatory texts on larger screens.

plurals
  1. POCABasicAnimation is ignored during rotation
    primarykey
    data
    text
    <p>I have a UIView that in the layoutSubviews method repositions its subviews based on the orientation of the iPad. Within the layoutSubviews method I have a CABasicAniamtion that is supposed to animate the repositioning of the subviews. The animations are set to specific duration but this duration is being ignored and repositioning happens immediately. I know the animations are firing because I am seeing the AnimationDidStart and AnimationDidStop methods being fired. I know this has something to do with the CALayers of the UIView but I can not find anything on the web to explain how to fix this. Any help would be appreciated.</p> <pre><code> if([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown) { NSLog(@"Orientation: Portrait"); //Hide icon CABasicAnimation *iconAnimation = [CABasicAnimation animationWithKeyPath:@"position"]; iconAnimation.fromValue = [NSValue valueWithCGPoint:[iconImageView center]]; iconAnimation.toValue = [NSValue valueWithCGPoint:iconThinPosition]; iconAnimation.duration = 2.7f; iconAnimation.autoreverses = NO; iconAnimation.repeatCount = 1; iconAnimation.delegate = self; [iconImageView.layer addAnimation:iconAnimation forKey:@"position"]; //[iconImageView setCenter:iconThinPosition]; [iconImageView.layer setPosition:iconThinPosition]; //[iconImageView setTransform: CGAffineTransformIdentity]; CABasicAnimation *textAnimation = [CABasicAnimation animationWithKeyPath:@"position"]; textAnimation.fromValue = [NSValue valueWithCGPoint:[textImageView center]]; textAnimation.toValue = [NSValue valueWithCGPoint:textThinPosition]; textAnimation.duration = 2.7f; textAnimation.autoreverses = NO; textAnimation.repeatCount = 1; textAnimation.delegate = self; [textImageView.layer addAnimation:textAnimation forKey:@"position"]; [textImageView.layer setPosition:textThinPosition]; } else if([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight) { NSLog(@"Orientation: Landscape"); // Show Icon CABasicAnimation *iconAnimation = [CABasicAnimation animationWithKeyPath:@"position"]; iconAnimation.fromValue = [NSValue valueWithCGPoint:[iconImageView center]]; iconAnimation.toValue = [NSValue valueWithCGPoint:iconShownPosition]; iconAnimation.duration = 2.7f; iconAnimation.autoreverses = NO; iconAnimation.repeatCount = 1; iconAnimation.delegate = self; [iconImageView.layer addAnimation:iconAnimation forKey:@"position"]; [iconImageView.layer setPosition:iconShownPosition]; CABasicAnimation *textAnimation = [CABasicAnimation animationWithKeyPath:@"position"]; textAnimation.fromValue = [NSValue valueWithCGPoint:[textImageView center]]; textAnimation.toValue = [NSValue valueWithCGPoint:textShownPosition]; textAnimation.duration = 2.7f; textAnimation.autoreverses = NO; textAnimation.repeatCount = 1; textAnimation.delegate = self; [textImageView.layer addAnimation:textAnimation forKey:@"position"]; [textImageView.layer setPosition:textShownPosition]; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload