いただきました次のコードで間違ってUIImageを設定する:これは間違っている場合はUIButton
UIButton *button = [[UIButton alloc]init];
CGRect frame = CGRectMake(180, 10, 33, 33);
button.frame = frame;
button.tag = 1001;
UIImage *image = [[[UIImage alloc]init]autorelease];
image = [UIImage imageNamed:@"icon.png"];
[button setBackgroundImage:image forState:UIControlStateNormal];
[image release];
[button release];
どこに補正し、なぜ必要なのでしょうか?
を試すことができますか?あなたはそれを試しましたか?それが動作しているかどうかを知る必要があります。 – smitec
これをIBで行う方がはるかに簡単です。ボタンを作成し、タイプをカスタムに設定して、イメージを設定します。これをプログラムで行う必要がある理由はありますか? – Osiris
私のために働いています。しかし、私は 'UIImage * image = [[UIImage alloc] init] autorelease]と言われました。 image = [UIImage imageNamed:@ "icon.png"]; 'は間違ったアプローチです。 –