-1

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

4

3 回答 3

3

您可以为表格视图的 frame 属性设置动画,以将其移出屏幕或移回屏幕。

下面是一些示例代码,可将表格视图移出屏幕并在屏幕上移动另一个视图:

[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 文档中阅读有关此类动画块的信息。

于 2011-09-08T04:03:04.193 回答
1

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

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

然后,当您完成 CustomViewController 时,请执行以下操作:

[self.navigationController popViewControllerAnimated:YES];
于 2011-09-08T02:34:25.683 回答
0

如果您使用UINavigationController. 它将负责滑动视图(将它们推到导航控制器堆栈上)和将它们滑出(将它们从导航控制器堆栈中弹出)。

于 2011-09-08T02:34:19.447 回答