[英]iOS: UITableView reload animation
我已经实现了嵌套的UITableViews
这样,在从父数据列表中选择特定行时,从服务器获取子节点数据并在同一个UITableview
重新加载它们。 我已经提供了使用字典返回父节点的规定,并且一切正常。 当我将父数据列表移动到子数据列表时,我想要导航样式动画。 有人可以帮助我如何做到这一点。
我尝试使用以下代码UIViewAnimationOptionTransitionFlipFromLeft
和UIViewAnimationOptionTransitionFlipFromRight
动画它翻转视图 - 我正在寻找类似但没有翻转 - 简单的导航样式动画,就像我想假装我正在推动另一个 UITableView。
[UIView transitionWithView: self.listTableView
duration: 0.35f
options: UIViewAnimationOptionTransitionFlipFromLeft
animations: ^(void) {
[self.listTableView reloadData];
} completion: ^(BOOL isFinished){
}];
这是带有代码的逻辑。
您需要QuartzCore framework in
.h 中导入QuartzCore framework in
才能使用以下代码。 AS #import
// Method to replace a given subview with another using a specified transition type, direction, and duration
-(void)replaceSubview:(UIView *)oldView withSubview:(UIView *)newView transition:(NSString *)transition direction:(NSString *)direction duration:(NSTimeInterval)duration
{
// Set up the animation
CATransition *animation = [CATransition animation];
// Set the type and if appropriate direction of the transition,
if (transition == kCATransitionFade)
{
[animation setType:kCATransitionFade];
}
else
{
[animation setType:transition];
[animation setSubtype:direction];
}
// Set the duration and timing function of the transtion -- duration is passed in as a parameter, use ease in/ease out as the timing function
[animation setDuration:duration];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[oldView layer] addAnimation:animation forKey:@"transitionViewAnimation"];
}
当 TableView 行被点击时调用 Above 方法,如下所示。
[self replaceSubview:thisTableView
withSubview:thisTableView
transition:kCATransitionPush
direction:kCATransitionFromLeft
duration:0.3];
//thisTableView is instance of UItableView.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.