Xcode 更新后过渡停止工作
Posted
技术标签:
【中文标题】Xcode 更新后过渡停止工作【英文标题】:Transitions Stopped Working after Xcode Update 【发布时间】:2019-11-04 15:41:51 【问题描述】:今天我更新了 Xcode,然后我在过去几年的所有应用程序中的所有转换都停止了工作。我测试了在新模拟器上运行它们并安装到 ios13.2 设备上。但是,当我从 App Store 下载我的任何应用程序时,过渡效果很好。稍后我将在试飞中尝试新版本。也许这些年来我一直在做错事?
转换代码
let details = self.storyboard?.instantiateViewController(withIdentifier: "ViewSettings")
details?.transitioningDelegate = self.slideAnimatorLeft
self.present(details!, animated: true, completion: nil)
过渡类
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 )
【问题讨论】:
【参考方案1】:将此行添加到您的代码中。
details?.modalPresentationStyle = .fullScreen
//完整代码
let details = self.storyboard?.instantiateViewController(withIdentifier: "CollectionViewController")
details?.transitioningDelegate = self.slideAnimatorLeft
details?.modalPresentationStyle = .fullScreen
self.present(details!, animated: true, completion: nil)
【讨论】:
【参考方案2】:尝试将您的modalPresentationStyle
更改为custom
,如下所示:
let details = self.storyboard?.instantiateViewController(withIdentifier: "ViewSettings")
details?.modalPresentationStyle = .custom
details?.transitioningDelegate = self.slideAnimatorLeft
self.present(details!, animated: true, completion: nil)
【讨论】:
以上是关于Xcode 更新后过渡停止工作的主要内容,如果未能解决你的问题,请参考以下文章
AppleWatch 模拟器和 iPhone 模拟器之间的 transferUserInfo 停止从 Xcode 11 工作
KeychainWrapperItem 在 iOS 7.1 中停止工作