Skip to content

Commit

Permalink
Fix iOS cell recycle
Browse files Browse the repository at this point in the history
  • Loading branch information
muak committed Apr 3, 2023
1 parent 297523a commit 32f70ab
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 0 additions & 2 deletions SettingsView/Handlers/CellBase/CellBaseHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ protected override TnativeCell CreatePlatformElement()
{
var reusableCell = VirtualView.ReusableCell;
var tv = VirtualView.TableView;
VirtualView.ReusableCell = null;
VirtualView.TableView = null;

return GetCell(VirtualView, reusableCell, tv);
}
Expand Down
1 change: 1 addition & 0 deletions SettingsView/Handlers/SettingsViewHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ protected override void DisconnectHandler(AiTableView platformView)
_insetTracker?.Dispose();
_insetTracker = null;

_tableview?.Dispose();
_tableview = null;

base.DisconnectHandler(platformView);
Expand Down
6 changes: 1 addition & 5 deletions SettingsView/Platforms/iOS/Cells/CellBaseView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ protected override void Dispose(bool disposing)

if(_cell != null)
{
CellParent.PropertyChanged -= ParentPropertyChanged;
_cell.PropertyChanged -= CellPropertyChanged;
if (_cell.Section != null)
{
Expand All @@ -588,11 +589,6 @@ protected override void Dispose(bool disposing)
//CellRenderer.SetRealCell(_cell, null);
_cell = null;
}

CellParent.PropertyChanged -= ParentPropertyChanged;




SelectedBackgroundView?.Dispose();
SelectedBackgroundView = null;
Expand Down
10 changes: 10 additions & 0 deletions SettingsView/Platforms/iOS/SettingsTableSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,16 @@ public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
protected override void Dispose(bool disposing)
{
if (!_disposed){

foreach(var section in _settingsView.Root)
{
foreach(var cell in section)
{
cell.ReusableCell = null;
cell.TableView = null;
}
}

foreach(var handler in _cellHandlers)
{
handler.DisconnectHandler();
Expand Down

0 comments on commit 32f70ab

Please sign in to comment.