gpt4 book ai didi

ios - 创建子类 C4Shapes(C4 框架)时获取未声明的标识符

转载 作者:行者123 更新时间:2023-12-04 00:45:25 27 4
gpt4 key购买 nike

我正在用 C4 编写一个程序,该程序由三个单独的按钮组成,按下时它们的形状都会发生变化。当我像这样为每个按钮创建一堆方法时:

@implementation MyButton

-(void)methodA {
C4Log(@"methodA");
[button1 ellipse:CGRectMake(centerPos.x - buttonWidth/2.0f, 80, buttonWidth, buttonHeight)];
}

-(void)methodB {
C4Log(@"methodB");
[button2 ellipse:CGRectMake(centerPos.x - buttonWidth/2.0f, centerPos.y - buttonHeight/2.0f, buttonWidth, buttonHeight)];
}

-(void)methodC{
C4Log(@"methodC");
[button3 ellipse:CGRectMake(centerPos.x - buttonWidth/2.0f, canvasHeight - 280, buttonWidth, buttonHeight)];
}

@end

...然后在 Canvas 中调用它们...

[button1 listenFor:@"touchesBegan" fromObject:button1 andRunMethod:@"methodA"];
[button2 listenFor:@"touchesBegan" fromObject:button2 andRunMethod:@"methodB"];
[button3 listenFor:@"touchesBegan" fromObject:button3 andRunMethod:@"methodC"];

...我最终得到的只是一堆未声明的标识符错误。我做错了什么?

最佳答案

我需要查看您在 MyButton.h 文件中定义的变量的副本才能确定,但​​据我从您的错误和代码中可以看出,以下行正在调用 ivars:

[button1 ellipse:CGRectMake(centerPos.x - buttonWidth/2.0f, 80, buttonWidth, buttonHeight)];

ivars centerPos、buttonWidth 和 buttonHeight 需要在您的 .h 文件中定义,如果其中一个未在此处声明,那么您将遇到此类错误。

关于ios - 创建子类 C4Shapes(C4 框架)时获取未声明的标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10253999/

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