如何让以下动画在块中工作?
(我需要键盘在转换动画的完成处理程序中消失)
- (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];
}
}
P.S;我知道,我正在删除并显示相同的视图。在调用此方法之前,此视图已收到新数据。某种程度上,视图显示正确,只显示“新”视图中的新数据。