UITableViewCell内でUIButtonを使用しています。このボタンは、以下のように選択できます。UITableViewCellが選択されたときにUIButtonが覆われる
問題は、セルが選択され、これまでと、ボタンが選択されているかどうかに関係なく、それは灰色に変わりますということである(この灰色はの非選択モードのグレー色とは異なっていますスター)。私はこれがなぜ起こるか把握しようとしていたが、運がなかった。ここ
電池はボタンが完全に消えます選択されたとき、私はボタンをタップしたときにも
- (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;
}
、細胞の実装です!
ありがとうございます、
あなたの質問にあなた自身の答えを受け入れることは大丈夫です。 –