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