如何滑动 - 在视图中为UITableView设置动画

时间:2011-09-08 02:06:12

标签: iphone objective-c ipad uitableview catransition

我想在点击按钮时将UITableVIew滑动到视图中(不是通过按导航控制器顶部的视图),然后通过滑动,单击相同的按钮将其隐藏回来。 我希望tableView在当前视图中滑动。

3 个答案:

答案 0 :(得分: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中阅读有关此类动画块的内容。

答案 1 :(得分:1)

查看UINavigationController的文档。要实现,你会做类似的事情:

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

然后,当您使用CustomViewController完成时:

[self.navigationController popViewControllerAnimated:YES];

答案 2 :(得分:0)

如果你使用UINavigationController,你可以免费获得漂亮的幻灯片动画。它将处理滑动视图(将它们推到导航控制器堆栈上)并将它们滑出(将它们弹出导航控制器堆栈)。

相关问题