4

我正在尝试模拟在 Readability 应用程序中看到的滑动 UIViewController。您可以将页面向右拖动,它将当前视图从堆栈中弹出以返回父 UIViewController,并带有如图所示的滑动动画:最右侧的视图位于顶部,并且被向右拖动,显示左边的原始表。

视图向右滑动

我已经尝试了一些slidingUIViewController 解决方案,例如ECSlidingViewController,但他们尝试模拟Facebook/Path 的行为,将slidingUIViewController 部分滑动到另一个之上,这不是Readability 所做的。

我也尝试过标准的水平滚动 UIScrollView 但滚动就像页面在两侧连接,而不是在另一个视图上滑动一个视图。

有谁知道他们是怎么做到的?

4

1 回答 1

0

This can be easily accomplished in few steps. I'm not going to write down all the code you need to write in order to do it, but just the steps you need to take. I will use a master-details terminology where the master view is the one from which you want to present a details view and the details view is of course the one at the top of the navigation stack.

When you want to present the detail view:

1) create an instance of the UIViewController that handles the interactions with the detailView. On iOS 5+ you can store this instance in the childrenViewControllers @property on the master's viewController. If you support a lower OS you should store the instance in an ivar.

2) set the detailView's frame to be outside the screen's bounds; add to detailView a shadow for graphical purposes. Finally add the detailView as a subview of the masterView.

3) (optional) add a pan gesture recognizer to the detailView in order to allow the user to swipe the view back and dismiss it.

4) animate the detailView in the screen's bounds. Make sure the interactions with the view below are disabled (be careful not to disable also the interactions with the detailsView!)

When you want to dismiss the detail view:

1) animate the detailView outside the screen's bounds.

2) remove it from it's superview and delete the reference to it's viewController.

3) re-enable the user interaction with the master view.

于 2013-02-20T13:06:59.137 回答