我正在尝试创建一个新的 UIImageView 并将其显示在主视图上,但是当我调用 [self.view addSubView:newBullet];
时,我收到错误 no visisble @interface for 'UIView' declarations the selector 'addSubView'
这是完整的方法
- (UIImageView *)shootNewBullet {
UIImageView *newBullet = [[UIImageView alloc] initWithFrame:CGRectMake(80, playerShip.center.y,15,3)];
newBullet.Image=[UIImage imageNamed: @"bullet2.png"];
newBullet.hidden = NO;
bulletMovement = 7;
[self.view addSubView:newBullet];
return newBullet;
该方法也在 .h 文件中为
-(UIImageView*)shootNewBullet;
我应该以某种方式将其连接到 View 吗?谢谢
最佳答案
是-[UIView addSubview:]不是 addSubView
.注意大小写,ObjC 区分大小写。
关于ios - UIImageView 错误没有可见的@interface for 'UIView' 声明选择器 'addSubView',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22057241/