ios - UIImageView 错误没有可见的@interface for 'UIView' 声明选择器 'addSubView'

标签 ios iphone objective-c uiview uiimageview

我正在尝试创建一个新的 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/

相关文章:

ios - 从承运人处获取位置而不是纬度/经度

ios - NSTimer 移动图像

android - 在没有服务器的情况下使用 SVGZ 文件。 (本地iOS/安卓)

objective-c - 具有 ARC 支持的静态库链接到导致链接器错误的非 ARC 项目

ios - physicsBody 与 spriteNode 未对齐

ios - UIImagePickerController使iPad上的应用程序崩溃,但iPhone崩溃

ios - cell.contentView systemLayoutSizeFittingSize : does not work for dynamic height tableview

ios - 如何设置规则以使用NEOnDemandRule类通过VPN自动连接?

iphone - UITextField setAutocapitalizationType 奇怪的行为

iphone - UIImageView 在 CAKeyframeAnimation 之后消失