How do I slide - animate a UITableView in a view

社会主义新天地 提交于 2019-12-10 00:31:39

问题


I want to slide a UITableVIew into a view (NOT by pushing the view on top of Navigation Controller) on click of a button and then hide it back by sliding , on clicking of the same button. I want the tableView to slide inside a present view.


回答1:


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.




回答2:


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



回答3:


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).



来源:https://stackoverflow.com/questions/7342404/how-do-i-slide-animate-a-uitableview-in-a-view

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