2012-02-11 25 views
4

だから私は以下のメソッド宣言と定義を持っている、エラー:宣言されていない識別子のエラー使用を

-(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; 
} 

この方法は、画像のビューを返します。

は私が宣言されていない識別子returnImageViewのコンパイラエラーの使用を与えている

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

としてそれを呼び出すようにしようとしています。エラーの原因は何ですか?

おかげで

答えて

4

すべて角括弧の第一は、コードの最後の行の後に不足しています。

2番目に「自己」をに、を取得してください!

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

第三に、あなたは、クラスの相対.hファイルにあなたreturnImageViewメソッドを宣言たのですか?

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

入力いただきありがとうございます。はい、私は自分自身を追加しましたが、メソッドが実行されていますが、画像ビューは追加されていないか、アプリが実行されたときに画像ビューを見ることができないため、問題はカラーパラメータになります。 –

+1

問題はイメージビューが初期化されていないため、これを行うことです。 UIImageView * myImageViews = [[UIImageView alloc] init]; 問題を解決しました –

+0

素晴らしい!そして、評判に感謝します! – erond

関連する問題