[cell addSubview:]
or
[cell.contentView addSubview:]
當我調(diào)用這個方法的時候,
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
區(qū)別在于進行cell編輯時,比如cell內(nèi)容向左移或者右移時,
第一種方式子視圖不會移動,
第二可以,所以這種情況一般使用第二種方式。
還有在設(shè)置backgroundColor/backgroundView時,使用cell設(shè)置時左移或者右移顏色是不會變的,而用cell.contentCell設(shè)置時,移動后的空白會顯示cell的默認顏色,這種情況視實際情況選擇。
其實這兩種方式在大多數(shù)情況是一樣,不用糾結(jié)。