简体   繁体   English

调用方法时出错:错误使用未声明的标识符

[英]error when calling a method: error use of undeclared identifier

So i have the below method declaration and definition, 所以我有以下方法声明和定义,

  -(UIImageView *)returnImageView:(UIImageView *)myImageView color:(UIColor *)imageViewColor x:(int)xParameter y:(int)yParamater width:(int)widthParameter height:(int)heightParameter
{  
CGRect cellFrame = CGRectMake(xParameter, yParamater, widthParameter, heightParameter);
style:UITableViewStyleGrouped];
myImageView = [myImageView initWithFrame:cellFrame];
myImageView.backgroundColor =imageViewColor;
myImageView.opaque = YES;
return myImageView;
}

This method will return an image view. 此方法将返回图像视图。

I am trying to call it as 我试着称之为

UIImageView *myImageViews;
UIColor *tableColor = [UIColor blueColor] ;
[self.view addSubview:[returnImageView:myImageViews color:tableColor x:17 y:10 width:290 height:230]; 

which is giving a compiler error use of undeclared identifier returnImageView. 这是一个编译器错误使用未声明的标识符returnImageView。 What is causing the error ? 是什么导致错误?

Thanks 谢谢

First of all a square bracket is missing after the last line of code. 首先,在最后一行代码后缺少方括号

Second you have to call " self " to get the method! 其次,你必须称“ 自我 ”来获得方法!

[self.view addSubview:[self returnImageView:myImageViews color:tableColor x:17 y:10 width:290 height:230]];

Third, did you declare your returnImageView method in the class-relative .h file ? 第三,你是否在类相对.h文件中 声明了returnImageView方法?

-(UIImageView *)returnImageView:(UIImageView *)myImageView color:(UIColor *)imageViewColor x:(int)xParameter y:(int)yParamater width:(int)widthParameter height:(int)heightParameter;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM