默认推送viewController动画不播放

时间:2019-03-06 14:31:15

标签: ios swift animation

我的应用程序中有一个浮动错误。 有时候,当我做

rootNavigationController.pushViewController(viewController, animated: animated)

动画不起作用。创建了新的viewController,并调用了方法viewWillAppear,但UI不变。新的viewController在屏幕外。

我使用连接连接到CALayer.add(_:forKey:)。 这是动画的堆栈跟踪,没有问题:

Thread 1 Queue : com.apple.main-thread (serial)
#0  0x00000001030ae890 in CALayer.swizz_add(_:forKey:)
#1  0x00000001030af468 in @objc CALayer.swizz_add(_:forKey:) ()
#2  0x000000018af12708 in -[UIViewAnimationState _trackAnimation:nonAdditiveAnimation:withAnimationKey:forKeyPath:inLayer:] ()
#3  0x000000018ba5dbe0 in __85+[UIViewPropertyAnimator _animationBlockForTrackingAnimation:animator:trackingSetup:]_block_invoke ()
#4  0x000000018afaa224 in -[UIViewPropertyAnimator _runAnimations] ()
#5  0x000000018ba64484 in __49-[UIViewPropertyAnimator startAnimationAsPaused:]_block_invoke_2 ()
#6  0x000000018ba642d4 in __49-[UIViewPropertyAnimator startAnimationAsPaused:]_block_invoke ()
#7  0x000000018ba643f8 in __49-[UIViewPropertyAnimator startAnimationAsPaused:]_block_invoke.1052 ()
#8  0x000000018afa9cbc in -[UIViewPropertyAnimator _setupAnimationTracking:] ()
#9  0x000000018afa96d4 in -[UIViewPropertyAnimator startAnimationAsPaused:] ()
#10 0x000000018afa79b4 in +[UIViewPropertyAnimator _trackAnimationWithAnimator:forLayer:forAnimationKey:trackingSetup:] ()
#11 0x000000018b00ea90 in +[UIViewPropertyAnimator _trackAdditiveAnimationWithAnimator:nonAdditiveAnimation:withAnimationKey:forKeyPath:forLayer:] ()
#12 0x000000018b1e0534 in __67-[_UIViewAdditiveAnimationAction runActionForKey:object:arguments:]_block_invoke.170 ()
#13 0x000000018aeab20c in -[_UIViewAdditiveAnimationAction runActionForKey:object:arguments:] ()
#14 0x0000000185338c24 in CA::Layer::set_position(CA::Vec2<double> const&, bool) ()
#15 0x000000018532aa24 in -[CALayer setPosition:] ()
#16 0x000000018532afd4 in -[CALayer setFrame:] ()
.....

当我遇到错误时,这里是堆栈跟踪:

#0  0x000000010488a554 in CALayer.swizz_add(_:forKey:)
#1  0x000000010488aefc in @objc CALayer.swizz_add(_:forKey:) ()
#2  0x000000018b1fb0ec in __modifyTrackedAnimationsWithFactory_block_invoke ()
#3  0x000000018b1ebdc4 in mapTrackedAnimations ()
#4  0x000000018b1ebb40 in +[UIView modifyTrackedAnimations:removeOnCompletion:animationFactory:block:] ()
#5  0x000000018ba5fe00 in -[UIViewPropertyAnimator _pauseAnimation:] ()
#6  0x000000018ba61080 in -[UIViewPropertyAnimator pauseAnimation] ()
#7  0x000000018afa79d8 in +[UIViewPropertyAnimator _trackAnimationWithAnimator:forLayer:forAnimationKey:trackingSetup:] ()
#8  0x000000018b00ea90 in +[UIViewPropertyAnimator _trackAdditiveAnimationWithAnimator:nonAdditiveAnimation:withAnimationKey:forKeyPath:forLayer:] ()
#9  0x000000018b1e0534 in __67-[_UIViewAdditiveAnimationAction runActionForKey:object:arguments:]_block_invoke.170 ()
#10 0x000000018aeab20c in -[_UIViewAdditiveAnimationAction runActionForKey:object:arguments:] ()
#11 0x0000000185338c24 in CA::Layer::set_position(CA::Vec2<double> const&, bool) ()
#12 0x000000018532aa24 in -[CALayer setPosition:] ()
#13 0x000000018532afd4 in -[CALayer setFrame:] ()
....

在第二种情况下,pauseAnimation被称为startAnimationAsPaused:的插入,并且为速度为0的关键点"UIPacingAnimationForAnimatorsKey""position"添加了动画。在哪里可以犯错? ? 这是设备和模拟器中的错误。 我不使用自定义过渡。

1 个答案:

答案 0 :(得分:0)

很可能是在您打滑的时候错误地实现了某些功能。尝试禁用它,并检查是否正在调用startAnimationAsPaused。如果它能按预期工作,那么请深入研究那些令人毛骨悚然的东西(最好看看您的代码),然后检查那里发生了什么。