2010-10-06 8 views
3

Je voudrais animer mon mouvement subviews lors de la rotation du dispositif, en changeant l'alpha à 0, déplacer la vue vers la nouvelle position et réinitialiser l'alpha à 1.Utilisation de blocs d'achèvement Handler dans iOS 4 pour l'animation

aide ce code dans didRotateFromInterfaceOrientation provoque l'affichage de la vue et disparaît très rapidement, puis réapparaît. Je voudrais éviter ce comportement.

[UIView animateWithDuration:kAnimationDuration animations:^{ 
    anObject.alpha = 0.0; 
    CGRect newFrame = anObject.frame; 
    newFrame.origin.x = newX; 
    newFrame.origin.y = newY; 
    newFrame.size.width = newWidth; 
    newFrame.size.height = newHeight; 
    anObject.frame = newFrame; 
} completion:^ (BOOL finished){ 
    if (finished) { 
     anObject.alpha = 1.0; 
    } 
}]; 

Y a-t-il un moyen de contourner ce clignotement?

Merci

Répondre

4

Peut-être réellement animer alpha sur l'achèvement? plutôt que de le flash? :)

[UIView animateWithDuration:kAnimationDuration animations:^{ 
anObject.alpha = 0.0; 
CGRect newFrame = anObject.frame; 
newFrame.origin.x = newX; 
newFrame.origin.y = newY; 
newFrame.size.width = newWidth; 
newFrame.size.height = newHeight; 
anObject.frame = newFrame; 
} completion:^ (BOOL finished){ 
if (finished) { 
[UIView animateWithDuration:kAnimationDuration 
           animations:^{ 
            anObject.alpha = 1;} 
} 
}]; 

Cheers, Krzysztof Zabłocki

+0

Il fait fanent plus agréable, mais un peu clignote soudainement. Merci quand même. – joec