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. What is causing the error ?
Thanks
The identifier is undeclaredIf the identifier is a variable or a function name, you must declare it before it can be used. A function declaration must also include the types of its parameters before the function can be used.
The identifier is undeclared: In any programming language, all variables have to be declared before they are used. If you try to use the name of a such that hasn't been declared yet, an “undeclared identifier” compile-error will occur.
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?
-(UIImageView *)returnImageView:(UIImageView *)myImageView color:(UIColor *)imageViewColor x:(int)xParameter y:(int)yParamater width:(int)widthParameter height:(int)heightParameter;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With