突出显示的TableView问题

时间:2011-05-29 17:12:20

标签: iphone objective-c xcode

我正在使用自定义的TableView,当我点击一个单元格并且它突出显示时我遇到了问题。单击单元格后,它会突出显示并转到另一个视图。问题是,当我返回TableView屏幕时,单元格仍然会突出显示。

这是我的代码:

在cellForRowAtIndexPath

cell.backgroundView = [[[UIImageView alloc] initWithImage:[UIImage 
imageNamed:@"CustomCell.png"]] autorelease];
cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CellHighlighted.jpg"]] autorelease];

在didSelectRowAtIndexPath

   Characteres *vCharacters = [[Characters alloc] initWithNibName:@"Characters" bundle:[NSBundle mainBundle]];
    //vCharacters.selectedCountry = selectedCountry;
    [self presentModalViewController:vCharactersr animated:YES];
    [vCharacters release];
    vCharacters = nil;*

1 个答案:

答案 0 :(得分:2)

您需要将其添加到didSelectRowAtIndexPath:

[tableView deselectRowAtIndexPath:indexPath animated:NO];

这将取消选择该行。