我在使用CAKeyframeAnimation时遇到了一个奇怪的错误,奇怪的部分是“SwiftDeferredNSArray doubleValue”,为什么我在处理关键帧动画时会得到它?
我得到以下跟踪,包含以下错误:
-[_TtCs21_SwiftDeferredNSArray doubleValue]: unrecognized selector sent to instance 0x12b55e060
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_TtCs21_SwiftDeferredNSArray doubleValue]: unrecognized selector sent to instance 0x12b55e060'
#0 0x0000000182ec0d58 in -[NSObject(NSObject) doesNotRecognizeSelector:] ()
#1 0x0000000182ebddcc in ___forwarding___ ()
#2 0x0000000182dbcc6c in _CF_forwarding_prep_0 ()
#3 0x0000000185b86b24 in CAObject_setValueForKeyPath_ ()
#4 0x0000000185b5b9e0 in -[CALayer setValue:forKeyPath:] ()
#5 0x0000000185c6ebd8 in -[CAKeyframeAnimation applyForTime:presentationObject:modelObject:] ()
#6 0x0000000185b5aabc in CA::Layer::presentation_layer(CA::Transaction*) ()
#7 0x0000000187f68b6c in _UIViewEatsTouches ()
#8 0x0000000187f68830 in -[UIView(Geometry) hitTest:withEvent:] ()
#9 0x000000018823f300 in -[UIView(Geometry) _hitTest:withEvent:windowServerHitTestWindow:] ()
#10 0x0000000187f68e2c in __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke ()
#11 0x0000000182dab954 in __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke ()
#12 0x0000000182dab84c in -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] ()
#13 0x0000000187f68950 in -[UIView(Geometry) hitTest:withEvent:] ()
#14 0x000000018823f300 in -[UIView(Geometry) _hitTest:withEvent:windowServerHitTestWindow:] ()
#15 0x0000000187f68e2c in __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke ()
#16 0x0000000182dab954 in __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke ()
#17 0x0000000182dab84c in -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] ()
#18 0x0000000187f68950 in -[UIView(Geometry) hitTest:withEvent:] ()
#19 0x00000001881f4cc8 in _UIApplicationHandleDigitizerEvent ()
#20 0x0000000187f2aab8 in _UIApplicationHandleEventQueue ()
#21 0x0000000182e703a4 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#22 0x0000000182e6fe38 in __CFRunLoopDoSources0 ()
#23 0x0000000182e6db38 in __CFRunLoopRun ()
#24 0x0000000182d98c60 in CFRunLoopRunSpecific ()
#25 0x000000018466c088 in GSEventRunModal ()
#26 0x0000000187f95fe4 in UIApplicationMain ()
#27 0x00000001001dd614 in main at /Users/MyApp/AppDelegate.swift:20
要求的附加代码:
override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
self.opacityView.layer.removeAnimationForKey("a")
if (self.focused)
{
self.opacityView.layer.addAnimation(a1, forKey: "a")
}
}
// Animation a1
let ani = CAKeyframeAnimation(keyPath: "transform.scale")
ani.timingFunctions = [CAMediaTimingFunction(controlPoints: 0.06,0.756,0.223,1.0)]
ani.values = [[1.0,1.0,1.0],[1.0*scaleFactor,1.0*scaleFactor,1.0*scaleFactor]]
ani.duration = 0.267
ani.fillMode = kCAFillModeForwards
ani.removedOnCompletion = false
答案 0 :(得分:1)
我知道这有点晚了,但我想我会给遇到此错误的其他人提供一个答案。据我所知,我猜你会看到这个因为ani.values
应该是一个单独的关键帧值数组,而不是数组数组。如,
ani.values = [1.0, 1.0*scaleFactor]