繁体   English   中英

我如何通过日期进行排序?

[英]How do I segue through dates?

想象一下,屏幕上的每个视图都显示了有关特定日期的一些信息。 向右滑动将日期提前一天,向左滑动显示昨天的数据。

我设法通过捕获滑动手势并更新屏幕上的数据来实现这一点,但我没有获得滑动动画。 我猜这样做的正确方法是将视图控制器与其自身进行连接并进行更新,但我不确定。 任何人都可以建议正确的方法来做到这一点吗?

每个方向都需要一个这样的块。 这是用于向右滑动(返回)。 另一个方向是相反的。

UIView.animateWithDuration(NSTimeInterval(0.1), animations: {
            //swipes view off screen
            self.calView.frame.origin.x = self.view.frame.width
        })
        UIView.animateWithDuration(NSTimeInterval(0), delay: NSTimeInterval(0.1), options: UIViewAnimationOptions(rawValue: 0), animations: {
            //jumps to other side
            self.calView.frame.origin.x = -self.view.frame.width
            }, completion: { _ in
                //reload data, subtract one, whatever
                self.setCurrentDate()
                self.collectionView?.reloadData()
        })
        UIView.animateWithDuration(NSTimeInterval(0.1), delay: NSTimeInterval(0.2), options: UIViewAnimationOptions(rawValue: 0), animations: {
            //swipes back to center
            self.calView.frame.origin.x = 0
            }, completion: nil)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM