我在VC中的UIButton单元格上有一个UITableView

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];


这是我的slideAction

-(void) slideAction
{
    [arrowBtnUp setBackgroundImage:[UIImage imageNamed:@"arrow_down.png"] forState:UIControlStateNormal];
    // also tried  with UIControlStateSelected/Highlighted
}


但这没有用。我找到了this链接但没有帮助。
任何建议或样品将不胜感激。

最佳答案

您的代码应该可以使用。无论如何都要更改代码,然后尝试

-(void) slideAction:(id)sender
{
   [sender setBackgroundImage:[UIImage imageNamed:@"arrow_down.png"] forState:UIControlStateNormal];
}




[arrowBtnUp addTarget:self action:@selector(slideAction:) forControlEvents:UIControlEventTouchUpInside];


并确保您的应用程序包中包含arrow_down.png

09-30 19:05