0
執行Peek和Pop後,我看到註冊了預覽視圖的控制器在釋放視圖後未釋放視圖的問題被釋放。
我創建了一個帶有的tableView一個簡單的項目,和ViewController註冊每個小區預覽如下:3D Peek和Pop內存泄漏
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
PeekCell *cell = [tableView dequeueReusableCellWithIdentifier:kPeekCellIdentifier forIndexPath:indexPath];
[self registerForPreviewingWithDelegate:self sourceView:cell];
return cell;
}
的問題是,如果我向上和向下滾動的細胞將被釋放,新的細胞會被創建。 viewController將註冊新的單元格進行預覽,並以這種方式增加內存。
問:我做錯了什麼?我應該何時打電話給unregisterForPreviewingWithContext
?
不,這不是一個解決方案,因爲在你的榜樣,我將永遠保存「previewingContext」最後顯示的單元格,所以我想更好的方法是添加一個'previewingContext'的數組,並在'didEndDisplayingCell'中註銷'indexPath' –
是的,那是正確的@ConstantinSaulenco – ystack