Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

fix crash on iOS 8 when entering-existing carousel caused by memory leak #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions txt/src/carouselView/dev/Shared.iOS/CarouselViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ protected override void OnElementChanged(ElementChangedEventArgs<CarouselView> e

// initialize properties
_position = Element.Position;
_controller.ReloadData(_position);

// hook up crud events
((ICarouselViewController)newElement).CollectionChanged += OnCollectionChanged;
Expand All @@ -233,8 +234,14 @@ protected override void Dispose(bool disposing)
if (disposing && !_disposed)
{
_disposed = true;
if (Element != null)
if (Element != null) {
((ICarouselViewController)Element).CollectionChanged -= OnCollectionChanged;
if(_controller != null) {
_controller.Dispose();
}
this.Control.Dispose();
this.Dispose();
}
}

base.Dispose(disposing);
Expand All @@ -248,12 +255,13 @@ public override void LayoutSubviews()
return;

base.Control.ReloadData();
_lastBounds = Bounds;


var wasPortrait = _lastBounds.Height > _lastBounds.Width;
var nowPortrait = Bounds.Height > Bounds.Width;
if (wasPortrait != nowPortrait)
_controller.ScrollToPosition(_position, false);

_lastBounds = Bounds;
}
public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
{
Expand Down