因此,用户选择绿色行,这将导致新控制器以绿色行大小开始并展开以填充屏幕.到目前为止,这部分工作正常.
我遇到的问题是解开segue,试图做相反的事情,将整个屏幕收缩回原来的行,然后解散.它会变得很好,但是暴露的区域仍然是黑色,然后在动画完成时突然闪烁到位.想要的是这样的:
但是发生的事情更像是这样的:
我用于展开的代码的代码如下:
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) } }}
所以基本上,当动画发生时,我如何获得我正在展开的视图?
为了完整起见,这里是前向segue代码:
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,dy: 0) window.insertSubvIEw(toVIEw,aboveSubvIEw: fromVIEw) UIVIEw.animateWithDuration(4000.milliseconds,animations: { toVIEw.frame = Box }) { (finished) in self.source.present(self.destination,completion: nil) } }}
(这是在XCode8中,使用Swift3针对iOS10)
解决方法 尝试让执行演示的视图控制器也执行解散.所以在你放松的时候:
UIVIEw.animateWithDuration(4000.milliseconds,animations: { fromVIEw.frame = targetFrame }) { (finished) in self.destination.dismiss(animated: false,completion: nil) // the destination is the one that presented the current vIEw }总结
以上是内存溢出为你收集整理的ios – 自定义展开segue动画显示问题全部内容,希望文章能够帮你解决ios – 自定义展开segue动画显示问题所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)