2013-01-17 55 views
1

我有一個IBOutlet UIButton,我添加到IB的滾動視圖中。我將其類型設置爲自定義,然後在viewDidLoad中我有:創建IB按鈕後,UIButton setImage不起作用

[self.featuredButton setImage:[UIImage imageNamed:@"featuredNormal.png"] forState:UIControlStateNormal]; 
[self.featuredButton setImage:[UIImage imageNamed:@"featuredSelected.png"] forState:UIControlStateSelected]; 

圖像不顯示...爲什麼不?

+0

它是連接到一個IB出口featuredButton? – kovpas

+0

是的...我不明白... – HackyStack

+1

這些文件只添加到我的目標之一,不得不將它們添加到其他目標中。呃...哎呀... – HackyStack

回答

0

使用

[self.featuredButton setBackgroundImage:[UIImage imageNamed:@"featuredNormal.png"] forState:UIControlStateNormal]; 

[self.featuredButton setBackgroundImage:[UIImage imageNamed:@"featuredSelected.png"] forState:UIControlStateSelected];