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