我在VC這樣更改objective-c中按鈕的背景圖像?
arrowBtnUp = [UIButton buttonWithType:UIButtonTypeCustom];
arrowBtnUp.frame = CGRectMake(50,(65-19)/2,31, 31);
[arrowBtnUp setBackgroundImage:[UIImage imageNamed:@"arrow_up.png"] forState:UIControlStateNormal];
[arrowBtnUp addTarget:self action:@selector(slideAction) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:arrowBtnUp];
上UITableView
細胞已經一個UIButton
這我slideAction
-(void) slideAction
{
[arrowBtnUp setBackgroundImage:[UIImage imageNamed:@"arrow_down.png"] forState:UIControlStateNormal];
// also tried with UIControlStateSelected/Highlighted
}
但事與願違幹活發現this聯繫,但並沒有幫助。 任何建議或示例,將不勝感激。
什麼不行?沒有圖像可見嗎?或者它不會更改爲arrow_down.png?你確定slideAction被執行嗎? –
「沒有工作」 - 更確切地說? – 2012-11-21 11:48:56
arrowBtnUp定義和/或存儲在哪裏以及如何將其放入單元格?它僅在一個單元中可見嗎? –