0

如何让以下动画分块工作?

(我需要键盘在过渡动画的完成处理程序中消失)

- (void) showNewViewAnimatedSlideAscending:(BOOL)isAscending {
    UIView * oldView = self.myView;
    UIView * newView = self.myView;
    UIView * superView = self.myView.superview;

    [oldView removeFromSuperview];
    [superView addSubview:newView];

    // set up an animation for the transition between the views
    CATransition *animation = [CATransition animation];
    [animation setDuration:0.3];
    [animation setType:kCATransitionPush];
    if(isAscending) {
        [animation setSubtype:kCATransitionFromRight];
    } else {
        [animation setSubtype:kCATransitionFromLeft];
    }
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

    [[superView layer] addAnimation:animation forKey:@"myTransitionAnimation"];
    if(self.keyboardVisible) {
        [self.view endEditing:YES];
    }
}  

ps; 我知道,我正在删除并显示相同的视图。此视图在调用此方法之前已接收到新数据。不知何故,视图正确显示,仅在“新”视图中显示新数据。

4

0 回答 0