【问题标题】:Why can't I do any CABasicAnimation or Keyframe animation stuff?为什么我不能做任何 CABasicAnimation 或关键帧动画的东西?
【发布时间】:2010-11-12 15:18:03
【问题描述】:

由于某种原因,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 时,我没有收到任何错误。所以我打赌 import 有效,但不确定。

已解决

我错过了包含 QuartzCore 框架!!

【问题讨论】:

  • 也许您可以不问这个问题,而是在此处保留 cmets 中的回复:stackoverflow.com/questions/1142727/…
  • 如果你写这篇文章是为了有一个明确的问题和一个明确的答案,让我告诉你:你的计划失败了!
  • 你应该把答案交给朱尔斯。

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


【解决方案1】:

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

#import <QuartzCore/QuartzCore.h>

QuartzCore 包含 CAAnimation 标头

【讨论】:

  • 是的,我包含了它。没有帮助。我会用更多细节更新问题。
  • 根据您在 qustion 中的“已解决”评论,这实际上是问题所在。不是吗?如果是这样,您应该将问题交给 Jason。
【解决方案2】:

可能您的项目中没有包含 Quartz 框架。

为此,请选择您的应用程序目标,转到 Build Phases 选项卡,然后在 Link Binary With Libraries 下添加 QuartzCore.framework.

【讨论】:

    猜你喜欢
    • 2017-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-16
    相关资源
    最近更新 更多