2011-09-08 52 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]; 
相关问题