刁钻的问题,我知道这是可能的,因为有几个应用程序这样做,特别是雷德做得很好。
在Reeder中,被弹出的视图控制器似乎不会从内存中删除,或者不管是什么典型的行为,因为在弹出并返回到前一个视图控制器之后,您可以从右向左滑向左看一点,如果您在离开前一个视图控制器之前滚动,您仍然可以看到滚动发生。这种快速跳转回您正在查看的视图控制器的能力,而不必从头开始预加载它们,正是我所要寻找的。
基本上,在iOS 7中,默认情况下,当您从视图控制器的左侧边缘向右滑动时,它会弹出导航堆栈。我喜欢从右边向左滑动的能力,这样就可以把它加回去。可以这样想,就像在web浏览器中,您可以在按回键后单击“前进”按钮。(或者在iOS 7的Safari中,您可以准确地做到这一点。)
默认情况下,这个功能是iOS 7的一部分,而我就是找不到它吗?或者有没有任何关于如何完成它的信息?
发布于 2013-12-01 09:10:44
这些选项取决于您试图支持的iOS版本。
- Create an animation controller that defines what the animation is to be. The animation controller is an object that conforms to `UIViewControllerAnimatedTransitioning`. (Note, it might seem odd to have to define a custom animation controller for something as standard as a push animation, but below you'll see we want a gesture recognizer to interface with an interaction controller, but you cannot define a custom interaction controller if you don't also define a custom animation controller.)
- Instantiate an interaction controller. You can create your own interaction controller class that conforms to `UIViewControllerInteractiveTransitioning`, but it's easiest to simply instantiate a`UIPercentDrivenInteractiveTransition` object.
- Now that you have the interaction controller, you can link a gesture recognizer (e.g. a `UIScreenEdgePanGestureRecognizer`), to it. The gesture recognizer will call calling the interaction controller's `updateInteractiveTransition` to specify the progress of the animation as it corresponds to the continuous gesture.
- Clearly, if you're going to recognize a swipe from the right edge as a "push" to a particular scene, then you'll have keep track of what that "next" scene is going to be. Sometimes you'll have a predefined series of view controllers. Sometimes you'll just keep an stack of view controllers that you previously popped from so that you can swipe from the right to push them back on. It just depends upon the desired UX.iOS 7客户转换提供了难以置信的控制,可以定制与交互过渡相关的动画和手势。但要做好这件事还需要做一些工作。
UIPageViewController。在iOS 6和更高版本中,您可以使用transitionStyle of UIPageViewControllerTransitionStyleScroll。(不幸的是,在iOS 5中,只有页面卷曲转换。)addChildViewController、removeChildViewController、willMoveToParentViewController、didMoveToParentViewController等)。请参阅查看控制器编程指南中的WWDC 2011视频实现UIViewController包容或创建自定义容器视图控制器部分。发布于 2014-03-02 03:26:03
我要做的是创建一个UINavigationController的自定义子类,并给它一个(强)属性lastPoppedVC。然后重写popViewControllerAnimated的实现,以保存弹出到lastPoppedVC的视图控制器。
此外,设置一个滑动手势识别器,从左到右的手势,将lastPoppedVC推回到堆栈上。这需要一些修改,因为我不认为您可以将手势识别器附加到导航控制器的内容视图中。您可能需要在每个VC上附加一个手势识别器,然后将其推到自定义导航控制器的堆栈上,并设计一种触发“回放”的方法。(您可能希望创建一个UIViewController类别,其中包含一个handleSwipeFromLeftGesture方法,该方法向拥有的导航控制器发送消息。)
发布于 2014-03-02 03:36:55
动画本身是没有问题的。下面是代码,如果您从右边拖动另一个视图控制器的视图来自右侧。这是一个选项卡条控制器,而不是导航控制器,但是所涉及的原则是完全相同的:
因此,从右边拖进来另一个视图控制器的姿态是非常简单的。
唯一的问题是解释从右边拖来的阻力在逻辑上意味着什么的问题。在我刚才指出的代码中,从左或右拖动意味着什么:它意味着“切换到视图控制器的左/右,如果有,”(在选项卡条控制器中)-我提供了逻辑使它做到这一点。在导航控制器的情况下,很明显,从左边拖动的意思是:“返回”。但是,我无法想象当用户从右边拖放时,您期望哪个视图控制器被推到堆栈上;您必须提供逻辑来指定这一点。
https://stackoverflow.com/questions/20308601
复制相似问题