How to mimic UINavigation animation behavior when transitioning between two UITableViews

隐身守侯 提交于 2019-12-11 05:16:49

问题


I have a UIViewController that houses two UITableViews and swaps between the two. I'm wondering how can I implement the exact same animation behavior that a UINavigationController does when transitioning between these two UITableViews? (ie one tableView gets pushed off the screen left to right or right to left by the other tableView).


回答1:


// Set table 2 up offscreen as starting state
CGRect rect = tableView2.frame;
rect.origin.x = rect.size.width;
tableView2.frame = rect;

// fill in any details you need for the animation
[UIView beginAnimation:...

// move 1 left offscreen
rect = tableView1.frame;
rect.origin.x = -rect.size.width;
tableView1.frame = rect;

// bring 2 right onscreen
rect = tableView2.frame;
rect.origin.x = 0;
tableView2.frame = rect;

[UIView commitAnimation];



回答2:


Any reason you cant use two UIViewController:s?

If not you should be able to do it by animating the bounds property of both table views. You could probaby also do it by using a paged scroll view and just switch beteween pages.



来源:https://stackoverflow.com/questions/7590404/how-to-mimic-uinavigation-animation-behavior-when-transitioning-between-two-uita

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