gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 17:53:41 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com