自定义选择cell的颜色

cell.selectionStyle=UITableViewCellSelectionStyleDefault;

cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];

cell.selectedBackgroundView.backgroundColor =[UIColor orangeColor];

 

设置选中第一行

[self.tableView selectRowAtIndexPath:

   [NSIndexPathindexPathForItem:0inSection:0]

   animated:YESscrollPosition:UITableViewScrollPositionTop];

if([self.tableView.delegaterespondsToSelector:

  @selector(tableView:didSelectRowAtIndexPath:)]) {

   [self.tableView.delegatetableView:

   self.tableView didSelectRowAtIndexPath:[NSIndexPathindexPathForItem:0inSection:0]];

}