Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 自定义展开序列动画显示问题_Ios_Swift_Uistoryboardsegue_Ios Animations - Fatal编程技术网

Ios 自定义展开序列动画显示问题

Ios 自定义展开序列动画显示问题,ios,swift,uistoryboardsegue,ios-animations,Ios,Swift,Uistoryboardsegue,Ios Animations,我正在制作我的第一个自定义segue动画。我想要的是有一个列表视图,当我在一行上选择时,它不是从侧面滑入,而是从所选行展开。比如: 因此,用户选择绿行,这将导致新控制器以绿行大小开始并展开以填充屏幕。到目前为止,这部分工作得很好 我遇到的问题是“放松”序列,它试图做相反的事情,将全屏缩小到原来的行,然后退出。发生的情况是,它收缩得很好,但暴露的区域仍然是黑色的,然后在动画完成时突然闪烁到位。我们需要的是这样的东西: 但现在发生的事情更像是这样: 我用于展开的perform的代码如下所示:

我正在制作我的第一个自定义segue动画。我想要的是有一个列表视图,当我在一行上选择时,它不是从侧面滑入,而是从所选行展开。比如:

因此,用户选择绿行,这将导致新控制器以绿行大小开始并展开以填充屏幕。到目前为止,这部分工作得很好

我遇到的问题是“放松”序列,它试图做相反的事情,将全屏缩小到原来的行,然后退出。发生的情况是,它收缩得很好,但暴露的区域仍然是黑色的,然后在动画完成时突然闪烁到位。我们需要的是这样的东西:

但现在发生的事情更像是这样:

我用于展开的
perform
的代码如下所示:

class FromScheduleFocusSegue: UIStoryboardSegue {
    override func perform() {
        let fromView = self.source.view!
        let toView = self.destination.view!
        let window = UIApplication.shared.keyWindow!
        let schedulesList = self.destination as! SchedulesListController
        let cell = schedulesList.tableView.cellForRow(at: schedulesList.tableView.indexPathForSelectedRow!)!
        var stripe = cell.bounds
        stripe.size.height = 60
        let targetFrame = cell.convert(stripe, to: window).insetBy(dx: 0, dy: 0)
        schedulesList.tableView.selectRow(at: nil, animated: false, scrollPosition: .none)
        UIView.animateWithDuration(4000.milliseconds, delay: 0.seconds, options: .curveEaseInOut, animations: {
            fromView.frame = targetFrame
        }) { (finished) in
            self.source.dismiss(animated: false, completion: nil)
        }
    }
}
所以,基本上,我如何获得我要展开的视图,以便在动画发生时显示出来

为完整起见,以下是转发序列代码:

class ToScheduleFocusSegue: UIStoryboardSegue {
    override func perform() {
        let fromView = self.source.view!
        let toView = self.destination.view!
        let window = UIApplication.shared.keyWindow!
        let box = UIScreen.main.bounds
        let schedulesList = self.source as! SchedulesListController
        let cell = schedulesList.tableView.cellForRow(at: schedulesList.tableView.indexPathForSelectedRow!)!
        toView.frame = cell.convert(cell.bounds, to: window).insetBy(dx: 0, dy: 0)
        window.insertSubview(toView, aboveSubview: fromView)
        UIView.animateWithDuration(4000.milliseconds, delay: 0.seconds, options: .curveEaseInOut, animations: {
            toView.frame = box
            }) { (finished) in
                self.source.present(self.destination, animated: false, completion: nil)
        }
    }
}

(这是在XCode8中,针对使用Swift3的iOS10)

尝试让执行演示的视图控制器也执行关闭

所以在你的放松阶段:

UIView.animateWithDuration(4000.milliseconds, delay: 0.seconds, options: .curveEaseInOut, animations: {
        fromView.frame = targetFrame
    }) { (finished) in
        self.destination.dismiss(animated: false, completion: nil) // the destination is the one that presented the current view
    }

没什么区别。我有点惊讶,我本以为会有一些不同,一个错误,或其他一些不同,但视觉行为是一样的,控制台输出中没有什么不同。你应该使用自定义转换来代替UIPresentationController和family。如果你能给我一个例子,让我朝着正确的方向前进,让我看到我想要的东西,赏金就归你了。我会更深入地了解UICollectionView。例如,请参见此处的“常规过渡的集合视图布局动画”部分