我用UIButton在我的UITableViewCell内,可以选择这个 but子,选择金星和未经选择的光球。
The problem is that when ever the cell is selected, no matter if the button is selected or not it will turn to a gray color (this gray color is different than the gray color of unselected mode of the star). I ve been trying to figure out why this happens, but had no luck.
here is the implementation of the cells,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
UIButton *button = [[UIButton buttonWithType:UIButtonTypeCustom]retain];
//set the background of the cells
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @"cellBackground.png"]];
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellselected2.png"]];
// set the button content
[button setImage:[UIImage imageNamed:@"star.png" ] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"starSelected.png"] forState:UIControlStateSelected];
[button addTarget:self action:@selector(selectedButton:) forControlEvents:UIControlEventTouchUpInside];
[button setFrame:CGRectMake(280, 10, 24, 24)];
[cell addSubview:button];
return cell;
}
也是当我主在选定牢房时的纽顿将彻底消失!
感谢