为什么我不能做任何CABasicAnimation或Keyframe动画的东西?

时间:2009-07-21 12:43:15

标签: iphone cocoa-touch uikit core-animation cabasicanimation

出于某种原因,Xcode告诉我,只要我使用像kCAFillModeForwards这样的东西就找不到符号。必须有一个图书馆或班级,我必须包括......但是哪一个?正常的核心动画的东西工作得很好[myView beginAnimations ...]。让更复杂的动画制作工作的诀窍是什么?

我已经加入了.h文件:

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

@interface TestClass : UIView {

}
// ...

我运行此代码:

- (void)testAnimation {
    CABasicAnimation *fadeInAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
    [fadeInAnimation setToValue:[NSNumber numberWithFloat:1.0]];
    fadeInAnimation.fillMode = kCAFillModeForwards;
    fadeInAnimation.removedOnCompletion = NO;
    // other stuff deleted to limit error possibilities...should at least compile
}

这种情况发生在我建立时(确实清理了很多次),2个错误:

    cd "/Users/thanks/Desktop/Thanks/iPhone Development/TestApp"
    setenv MACOSX_DEPLOYMENT_TARGET 10.5
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.0 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk "-L/Users/thanks/Desktop/Thanks/iPhone Development/TestApp/build/Debug-iphonesimulator" "-F/Users/thanks/Desktop/Thanks/iPhone Development/TestApp/build/Debug-iphonesimulator" -filelist "/Users/thanks/Desktop/Thanks/iPhone Development/TestApp/build/TestApp.build/Debug-iphonesimulator/TestApp.build/Objects-normal/i386/TestApp.LinkFileList" -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework CoreGraphics -o "/Users/thanks/Desktop/Thanks/iPhone Development/TestApp/build/Debug-iphonesimulator/TestApp.app/TestApp"
Undefined symbols:
  ".objc_class_name_CABasicAnimation", referenced from:
      literal-pointer@__OBJC@__cls_refs@CABasicAnimation in TestClassTestClass.o
  "_kCAFillModeForwards", referenced from:
      _kCAFillModeForwards$non_lazy_ptr in TestClass.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
      ".objc_class_name_CABasicAnimation", referenced from:
          literal-pointer@__OBJC@__cls_refs@CABasicAnimation in TestClass.o
      "_kCAFillModeForwards", referenced from:
          _kCAFillModeForwards$non_lazy_ptr in TestClass.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status

它表示未定义的符号:

我必须包含一些框架吗?

我已经包括:

CoreGraphics.framework Foundation.framework UIKit.framework

当我删除所有代码,但导入QuartzCore / QuartzCore.h时,我没有收到任何错误。所以我打赌导入有效,但不确定。

解决

我错过了包含QuartzCore框架!!

2 个答案:

答案 0 :(得分:7)

您是否在标题中导入石英?

#import <QuartzCore/QuartzCore.h>

QuartzCore包含CAAnimation标头

答案 1 :(得分:7)

可能你没有在项目中包含Quartz框架。

为此,请选择您的应用目标,转到构建阶段标签,然后在链接二进制文件库下添加 QuartzCore.framework