不是bug 是教训

方法设置tableView的cell的背景。

先设置好选中背景

cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"xx.png"]] autorelease];

设置选中

[tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];

注意 文档中的方法 [cell setSelected:YES]; 无效;

教训是指:一定要吧xx.png导入工程,否则真机上找不到该图片(如果是模拟器显示没问题)。

原文地址:https://www.cnblogs.com/tiechui/p/2168829.html