Reputation: 522
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
Upvotes: 5
Views: 5866
Reputation: 270
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;
Upvotes: 7