2010-07-25 80 views

回答

14

執行以下任一方法。當從表格中移除時,超級視圖將變爲零。當添加回表格時,superview將被設置爲表格視圖。

- (void)willMoveToSuperview:(UIView *)newSuperview; 
- (void)didMoveToSuperview; 

另見

- (void)prepareForReuse; 
+1

它不會在iOS 6.x中工作我已經實現了所有3種方法,willMoveToSuperview和didMoveToSuperview只會在我第一次滾動tableview時被調用。每當我滾動表格視圖時,prepareForReuse就會被調用。所以不可能通過前兩種方法確定單元格是否已從表格視圖中移除。 3.方法在重用時調用,而不是從tableview中刪除。 – Mert 2013-09-17 08:45:55

4

IOS 6.0之後你的UITableViewDelegate以下方法

- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 


Use this method to detect when a cell is removed from a table view, as opposed to monitoring the view itself to see when it appears or disappears. 
+1

我認爲你的意思是> = iOS6。 – 2015-08-09 22:41:08