我意识到这个错误已经在 stackoverflow 上讨论过很多次,但我仍然不确定我错过了什么。这是控制台输出:
Unknown class CRBarGraphController in Interface Builder file.
2014-11-18 18:40:05.796 Test[7319:60b] -[UIImageView start2]: unrecognized selector sent to instance 0x16562ac0
2014-11-18 18:40:06.256 Test[7319:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView start2]: unrecognized selector sent to instance 0x16562ac0'
CRBarGraphController.m
定义了一个(void)start2;
也在接口中声明的函数CRBarGraphController.h
。
CRGraphViewController.m
使用以下代码调用 start2 :
-(void)viewWillAppear:(BOOL)animated {
self.navigationController.navigationBarHidden = NO;
[self.bar_Graph start2];
}
其中, bar_Graph 是 的对象CRBarGraphController
,声明CRGraphViewController.h
为:
@property (weak, nonatomic) IBOutlet CRBarGraphController *bar_Graph;
CRGraphViewController.h
确实导入CRBarGraphController.h
此外,在情节提要中, bar_Graph 出口设置为 class, CRBarGraphController
.
为什么 XCode 仍然认为 bar_Graph 是UIImageView
and not的一个实例CRBarGraphComtroller
?我包含了一个异常断点,以确保异常源自调用 start2 的位置。