首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xcode更新后,转换停止工作

Xcode更新后,转换停止工作
EN

Stack Overflow用户
提问于 2019-11-04 23:41:52
回答 2查看 72关注 0票数 3

今天我更新了Xcode,然后我过去几年在所有应用程序中的所有过渡都停止工作了。我在新的模拟器上以及通过安装到iOS13.2设备上测试了它们的运行情况。然而,当我从App Store下载我的任何应用程序时,转换都工作得很好。我将在稍后的试飞中尝试新的构建。也许这些年来我做错了什么?

转换代码

代码语言:javascript
复制
let details = self.storyboard?.instantiateViewController(withIdentifier: "ViewSettings")
details?.transitioningDelegate = self.slideAnimatorLeft
self.present(details!, animated: true, completion: nil)

转换类

代码语言:javascript
复制
class SlideAnimatorLeft: NSObject, UIViewControllerAnimatedTransitioning, UIViewControllerTransitioningDelegate {

    let duration = 0.9

    func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return self
    }

    func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return self
    }

    func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
        return duration
    }

    func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
        guard let fromView = transitionContext.view(forKey: UITransitionContextViewKey.from) else {
            return
        }

        guard let toView = transitionContext.view(forKey: UITransitionContextViewKey.to) else {
            return
        }

        let container = transitionContext.containerView

        let screenOffUp = CGAffineTransform(translationX: container.frame.width, y: 0)
        let screenOffDown = CGAffineTransform(translationX: -container.frame.width, y: 0)

        container.addSubview(fromView)
        container.addSubview(toView)

        toView.transform = screenOffUp

        UIView.animate(withDuration: duration, delay: 0.0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0.8, options: [], animations: {

            fromView.transform = screenOffDown
            fromView.alpha = 1
            toView.transform = CGAffineTransform.identity
            toView.alpha = 1

        }) { (success) in
            transitionContext.completeTransition(success )
        }
    }
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-11-04 23:54:46

将此行添加到您的代码中。

代码语言:javascript
复制
 details?.modalPresentationStyle = .fullScreen 

//完整代码

代码语言:javascript
复制
 let details = self.storyboard?.instantiateViewController(withIdentifier: "CollectionViewController")
 details?.transitioningDelegate = self.slideAnimatorLeft
 details?.modalPresentationStyle = .fullScreen
 self.present(details!, animated: true, completion: nil)
票数 2
EN

Stack Overflow用户

发布于 2019-11-04 23:57:22

尝试将modalPresentationStyle更改为custom,如下所示:

代码语言:javascript
复制
let details = self.storyboard?.instantiateViewController(withIdentifier: "ViewSettings")
details?.modalPresentationStyle = .custom
details?.transitioningDelegate = self.slideAnimatorLeft
self.present(details!, animated: true, completion: nil)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58696677

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档