2011-09-08 49 views
-1

我想通過單擊按鈕將UITableVIew滑動到視圖中(而不是通過推動導航控制器頂部的視圖),然後通過滑動將其隱藏起來同一個按鈕。 我想讓tableView在當前視圖內滑動。如何滑動 - 在視圖中爲UITableView設置動畫

+3

你試過嗎?嘗試編寫一個動畫塊,將視圖移動到屏幕上並將其移開,然後執行它。在考慮動畫時,你應該首先查看的是[查看動畫](http://developer.apple.com/library/iOS/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/AnimatingViews/AnimatingViews.html#//apple_ref/doc/uid/TP40009503-CH6-SW1)的工作。 – darvids0n

回答

3

您動畫表視圖的框架屬性來移動它關閉屏幕或回到屏幕上。

這裏是一個移動的表中查看關閉屏幕,並在它的地方移到另一個屏幕上的一些示例代碼:

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:kSlideTableDuration]; 
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; 
[UIView setAnimationDelegate:self]; 
[UIView setAnimationDidStopSelector:@selector(tableAnimationDidStop:finished:context:)]; 

self.tableView1.frame = offScreen; 
self.tableView2.frame = onScreen; 

[UIView commitAnimations];      

你可以閱讀有關在UIView documentation動畫塊這樣的。

0

如果您使用UINavigationController,您將獲得免費的幻燈片動畫。它將處理滑動視圖(將它們推到導航控制器堆棧上)並將它們滑出(將它們從導航控制器堆棧彈出)。

1

查閱UINavigationController的文檔。要實現你會做一些與此類似:

iPhoneCustomViewController *newView = [[iPhoneCustomViewController alloc] initWithNibName:@"iPhoneCustomViewController" bundle:nil]; 
[self.navigationController pushViewController:newView animated:YES]; 
[newView release]; 

然後,當你與CustomViewController做做:

[self.navigationController popViewControllerAnimated:YES]; 
相關問題