Objective c 目标-C–;未定义的符号
我试着在cocoa touch中使用渐变。我正在为此使用以下代码:Objective c 目标-C–;未定义的符号,objective-c,cocoa-touch,Objective C,Cocoa Touch,我试着在cocoa touch中使用渐变。我正在为此使用以下代码: #import <QuartzCore/QuartzCore.h> CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = mainView.bounds; gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] CGColor], (id)[[UI
#import <QuartzCore/QuartzCore.h>
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = mainView.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] CGColor], (id)[[UIColor whiteColor] CGColor], nil];
[mainView.layer insertSublayer:gradient atIndex:0];
#导入
CAGradientLayer*梯度=[CAGradientLayer层];
gradient.frame=mainView.bounds;
gradient.colors=[NSArray arrayWithObjects:(id)[[UIColor blackColor]CGColor],(id)[[UIColor whiteColor]CGColor],nil];
[mainView.layer insertSublayer:gradient atIndex:0];
但我在尝试编译时遇到以下错误:
架构i386的未定义符号:“_OBJC_CLASS_$_CAGradientLayer”,引用自: OfficeViewController.o ld中的objc类引用:未找到符号 对于体系结构i386 collect2:ld返回1退出状态
我试着做一次清洁,但没有用。不确定我还能做什么?您是否也将QuartzCore框架包括在项目中?仅仅添加标题是不够的。确保您的项目中实际包含了QuartzCore框架。它应处于链接二进制库阶段:
谢谢。但是为什么我可以使用一些QuartzCore函数(不添加QuartzCore框架),比如layer属性?这里详细说明了到达该屏幕的步骤:另一个问题是,当您这样做时,Xcode可能会添加框架,但目标错误。确保为要构建的目标选择了框架