我在UITableView标题
中创建了一个带有不同状态图像的按钮 -(UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
self.filterButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.filterButton setBackgroundImage:[UIImage imageNamed:@"g29_fctn_filter_default"] forState:UIControlStateNormal];
[self.filterButton setBackgroundImage:[UIImage imageNamed:@"g31_fctn_filter_applied"] forState:UIControlStateSelected];
[self.filterButton setBackgroundImage:[UIImage imageNamed:@"g30_fctn_filter_active"] forState:UIControlStateHighlighted];
self.filterButton.frame = CGRectMake((self.myTableView.frame.size.width / 2) - 60, 10, 44, 32);
[self.filterButton addTarget:self action:@selector(filterButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
//imageView.contentMode = UIViewContentModeScaleAspectFit;
[view addSubview:self.filterButton];
return view;
}
当我将按钮状态设置为以编程方式选择时,我看不到UIButton图像更改,它仍然显示为forState设置的图像:UIControlStateNormal
-(void) filterButtonPressed:(id)sender
{
[self.filterButton setSelected:YES];
}