当选择UITableViewCell时使用默认的蓝色背景

问题描述:

为了更好的用户体验,我希望我的UITableViewCell在用户点击时具有默认的蓝色样式。目前,根本没有造型。这不是我需要的吗?当选择UITableViewCell时使用默认的蓝色背景

- (void)tableView:(UITableView *)tableView 
    didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [tableView selectRowAtIndexPath:indexPath 
     animated:NO scrollPosition:UITableViewScrollPositionNone]; 
    // [The rest of my code here that loads up the detail view] 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView 
    cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // [bunch of code] 
    UITableViewCell *cell = [[[UITableViewCell alloc] 
     initWithStyle:UITableViewCellStyleSubtitle 
     reuseIdentifier:PlaceholderCellIdentifier] autorelease]; 
    // [bunch of code that sets the text of the cell]; 
    return cell; 
} 

转到的cellForRowAtIndexPath和使用

cell.selectionStyle= UITableViewCellSelectionStyleBlue; 
+0

这解决了这个问题。我不知道为什么。根据[UITableViewCell文档](http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITableViewCell_Class/Reference/Reference.html),“UITableViewCellSelectionStyleBlue”已经是默认样式。另外,我已经看到其他示例代码没有重新定义这个默认样式,但是在单元被点击时正确显示样式。 – JoJo 2011-06-07 19:33:05