定義一個屬性記錄selectedIndexPath用來記錄選中的行的indexpath,在視圖控制器初始化方法中初始化此屬性為nil, 在tableView:didSelectRowAtIndexPath代理方法中: 首先deselect這個行 然后[tableView beginUpdate] if(selectedIndexPath==nil) { selectedIndexPath=indexPath; [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; } else{ bool hasSelectedOtherRow=![self.selectedIndexPath isEqualTo:indexPath]; NSIndexPath *temp=self.selectedIndexPath; self.selectedIndexPath=nil; [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:temp] withRowAnimation:UITableViewRowAnimationAutomatic]; if(hasSelectedOtherRow){ self.selectedIndexPath=indexPath; [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; } } [tableView endUpdate]; 在返回行高的代理方法中,如果indexPath等於self.selectedIndexPath, 返回一個特定的高度,否則返回缺省單元格高度。 在返回單元的代理方法中,如果indexPath等於self.selectedIndexPath,返回一個定制的單元(這個特定單元可以在視圖控制器的viewdidload方法中初始化,不需要重用)否則返回缺省單元。