我一直在查看有关此错误的无数帖子:
Undefined symbols:
"_OBJC_CLASS_$_BoxView", referenced from:
objc-class-ref-to-BoxView in ViewMovingViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
BoxView是一个子类UIView,并且UIKit框架已包含在内.BoxView.h已在ViewController中导入.
ViewController包含以下代码:
-(void) addBoxViewAtLocation:(CGPoint)point {
CGRect rect;
rect.origin.x = point.x;
rect.origin.y = point.y;
rect.size.width = 80;
rect.size.width = 40;
BoxView *newView = [[BoxView alloc] initWithFrame:rect];
newView.backgroundColor = [UIColor yellowColor];
[mainView addSubview:newView];
}
Run Code Online (Sandbox Code Playgroud)
并BoxView包含此代码:
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
// no further initialization
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
这是导致错误的行,来自上面的代码: …