[英]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.