Iphone 单击时亮显表格视图单元格,而不是在发布时亮显

Iphone 单击时亮显表格视图单元格,而不是在发布时亮显,iphone,ios,uitableview,Iphone,Ios,Uitableview,我有一个带有项目列表的表视图。当我单击其中一个项目时,我希望背景突出显示。我有代码工作,但颜色在发布时改变,而不是点击本身。当用户点击手机时,而不是当他/她释放手机时,我如何突出显示 这是我的密码: -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ // Navigation logic may go here. Create and push anoth

我有一个带有项目列表的表视图。当我单击其中一个项目时,我希望背景突出显示。我有代码工作,但颜色在发布时改变,而不是点击本身。当用户点击手机时,而不是当他/她释放手机时,我如何突出显示

这是我的密码:

-(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"]];
}
我希望它像按钮一样发生。除了
didSelectRowAtIndexPath
,UITableView或UITableView单元格是否还有
onClick
方法

编辑

这是我的代码,来自
cellforrowatinexpath

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

}

在创建单元格时,在cellForRowAtIndexPath中,编写以下代码:

UIView *v=[[UIView alloc] initWithFrame:cell.frame];
v.backgroundColor = [self colorForHex:[appDel.appColorSettings objectForKey:@"cellColor2"]];
    cell.selectedBackgroundView = v;

不需要用DIDELISTROW方法写任何东西。

你可以认为这是选项

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

[tableView selectRowAtIndexPath:indexPath.row animated:YES scrollPosition:UITableViewScrollPositionTop];

}

我喜欢这个想法,但将它添加到我的
cellforrowatinexpath
中是行不通的。如果我将另一个
UIView v
设置为背景视图,这会受到影响吗?您应该为selectedBackgroundView添加它。不是背景视图。如果你有其他的观点作为背景,这不会有任何问题。也发布一些代码,这样我就可以检查了。在我的编辑中,我有一个
单元格。selectionStyle=UITableViewCellSelectionStyleNone将删除我正在添加的任何选定样式。谢谢你的帮助