How do I slide - animate a UITableView in a view

2019-04-18 03:40发布

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.

3条回答
贼婆χ
2楼-- · 2019-04-18 03:58

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.

查看更多
时光不老,我们不散
3楼-- · 2019-04-18 04:06

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];
查看更多
狗以群分
4楼-- · 2019-04-18 04:07

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

查看更多
登录 后发表回答