アイテムのリストを含むテーブル ビューがあります。それらの項目の 1 つをクリックすると、背景が強調表示されます。そのコードは機能していますが、クリック自体ではなく、リリース時に色が変わります。ユーザーがセルを離したときではなく、セルをタップしたときに強調表示するにはどうすればよいですか?
これが私のコードです:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
// Navigation logic may go here. Create and push another view controller.
Help_Cell *cell =(Help_Cell*) [tableView cellForRowAtIndexPath:indexPath];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
UIView *v=[[UIView alloc] initWithFrame:cell.frame];
v.backgroundColor=[self colorForHex:[appDel.appColorSettings objectForKey:@"cellColor2"]];
cell.backgroundView=v;
cell.title.textColor=[self colorForHex:[appDel.appColorSettings objectForKey:@"cellColor1"]];
}
私はそれがボタンのように起こることを望みます。onClick
以外に UITableView または UITableViewCellのメソッドはありますdidSelectRowAtIndexPath
か?
編集
これが私のコードですcellForRowAtIndexPath
-(void)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
Help_Cell *cell =(Help_Cell*) [tableView cellForRowAtIndexPath:indexPath];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
UIView *v=[[UIView alloc] initWithFrame:cell.frame];
v.backgroundColor=[self colorForHex:[appDel.appColorSettings objectForKey:@"cellColor2"]];
cell.selectedBackgroundView=v;
}