How do I slide - animate a UITableView in a view

若如初见. 提交于 2019-12-04 23:29:30

You animate the frame property of the table view to move it off screen or back onto screen.

Here is some sample code that moves a table view off screen and moves another on screen in its place:

[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];                      

You can read about animation blocks like this in the UIView documentation.

Check out the documentation of UINavigationController. To implement you would do something similar to this:

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

Then, when your done with the CustomViewController do:

[self.navigationController popViewControllerAnimated:YES];

You get the nice slide animations for free if you use a UINavigationController. It will take care of sliding views in (push them on the navigation controller stack) and sliding them out (pop them off the navigation controller stack).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!