Cannot find protocol declaration for "CAAnimationDelegate"

My code was fine, but it tells me:

cannot find protocol declaration for 'CAAnimationDelegate';did you mean 'UIApplicationDelegate'? 

when i run it today.

I tried importing QuartzCore/CAAnimation.h but it does not work.

+5
source share
2 answers

CAAnimationDelegate is not a protocol. There is no need to report that your class is going to implement CAAnimationDelegate .

First you need to import QuartzCore / QuartzCore.h . Then you just pass your class (in which you want to implement animation delegation methods) as a delegate to your CAAnimation . It will automatically call animationDidStart when the animation starts and calls the animationDidStop method when the animation finishes.

+3
source

CAAnimationDelegate is a new protocol that has been added to the iOS 10 SDK. This means that it exists if you create with Xcode 8, but not there if you create with Xcode 7.

When you create with Xcode 8, you will get a warning:

 Assigning to 'id<CAAnimationDelegate> _Nullable' from incompatible type 'WhateverUIViewController *const __strong' 

If you add CAAnimationDelegate, your code will no longer be created in Xcode 7. If you need to build using both Xcode, you need to use ifdefs:

 #if __IPHONE_OS_VERSION_MAX_ALLOWED < 100000 // CAAnimationDelegate is not available before iOS 10 SDK @interface WhateverUIViewController () #else @interface WhateverUIViewController () <CAAnimationDelegate> #endif 
+18
source

All Articles