summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Maps.iOS
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2017-01-16 12:36:49 -0700
committerRui Marinho <me@ruimarinho.net>2017-01-16 19:36:49 +0000
commit5fec30f288fffd6ad7c11a0557c809f3befdd79a (patch)
tree122afcc742a7546169df9bf16c204de76955e24b /Xamarin.Forms.Maps.iOS
parentec8bcd443a20d79f06bc2de1ba6b463c03f63d47 (diff)
downloadxamarin-forms-5fec30f288fffd6ad7c11a0557c809f3befdd79a.tar.gz
xamarin-forms-5fec30f288fffd6ad7c11a0557c809f3befdd79a.tar.bz2
xamarin-forms-5fec30f288fffd6ad7c11a0557c809f3befdd79a.zip
Pool and reuse MKMapView instances on iOS 9 as well as iOS 10 (#680)
Diffstat (limited to 'Xamarin.Forms.Maps.iOS')
-rw-r--r--Xamarin.Forms.Maps.iOS/FormsMaps.cs11
-rw-r--r--Xamarin.Forms.Maps.iOS/MapRenderer.cs14
2 files changed, 18 insertions, 7 deletions
diff --git a/Xamarin.Forms.Maps.iOS/FormsMaps.cs b/Xamarin.Forms.Maps.iOS/FormsMaps.cs
index 19c0701e..a87cb8dc 100644
--- a/Xamarin.Forms.Maps.iOS/FormsMaps.cs
+++ b/Xamarin.Forms.Maps.iOS/FormsMaps.cs
@@ -7,6 +7,7 @@ namespace Xamarin
{
static bool s_isInitialized;
static bool? s_isiOs8OrNewer;
+ static bool? s_isiOs9OrNewer;
static bool? s_isiOs10OrNewer;
internal static bool IsiOs8OrNewer
@@ -19,6 +20,16 @@ namespace Xamarin
}
}
+ internal static bool IsiOs9OrNewer
+ {
+ get
+ {
+ if (!s_isiOs9OrNewer.HasValue)
+ s_isiOs9OrNewer = UIDevice.CurrentDevice.CheckSystemVersion(9, 0);
+ return s_isiOs9OrNewer.Value;
+ }
+ }
+
internal static bool IsiOs10OrNewer
{
get
diff --git a/Xamarin.Forms.Maps.iOS/MapRenderer.cs b/Xamarin.Forms.Maps.iOS/MapRenderer.cs
index cc9f2533..794a4a04 100644
--- a/Xamarin.Forms.Maps.iOS/MapRenderer.cs
+++ b/Xamarin.Forms.Maps.iOS/MapRenderer.cs
@@ -137,13 +137,13 @@ namespace Xamarin.Forms.Maps.iOS
return Control.GetSizeRequest(widthConstraint, heightConstraint);
}
- // iOS 10 has some issues with releasing memory from map views; each one we create allocates
+ // iOS 9/10 have some issues with releasing memory from map views; each one we create allocates
// a bunch of memory we can never get back. Until that's fixed, we'll just reuse MKMapViews
// as much as possible to prevent creating new ones and losing more memory
// For the time being, we don't want ViewRenderer handling disposal of the MKMapView
- // if we're on iOS 10; during Dispose we'll be putting the MKMapView in a pool instead
- protected override bool ManageNativeControlLifetime => !FormsMaps.IsiOs10OrNewer;
+ // if we're on iOS 9 or 10; during Dispose we'll be putting the MKMapView in a pool instead
+ protected override bool ManageNativeControlLifetime => !FormsMaps.IsiOs9OrNewer;
protected override void Dispose(bool disposing)
{
@@ -170,14 +170,14 @@ namespace Xamarin.Forms.Maps.iOS
mkMapView.Delegate = null;
mkMapView.RemoveFromSuperview();
- if (FormsMaps.IsiOs10OrNewer)
+ if (FormsMaps.IsiOs9OrNewer)
{
// This renderer is done with the MKMapView; we can put it in the pool
// for other rendererers to use in the future
MapPool.Add(mkMapView);
}
- // For iOS versions < 10, the MKMapView will be disposed in ViewRenderer's Dispose method
+ // For iOS versions < 9, the MKMapView will be disposed in ViewRenderer's Dispose method
if (_locationManager != null)
{
@@ -208,7 +208,7 @@ namespace Xamarin.Forms.Maps.iOS
{
MKMapView mapView = null;
- if (FormsMaps.IsiOs10OrNewer)
+ if (FormsMaps.IsiOs9OrNewer)
{
// See if we've got an MKMapView available in the pool; if so, use it
mapView = MapPool.Get();
@@ -216,7 +216,7 @@ namespace Xamarin.Forms.Maps.iOS
if (mapView == null)
{
- // If this is iOS 9 or lower, or if there weren't any MKMapViews in the pool,
+ // If this is iOS 8 or lower, or if there weren't any MKMapViews in the pool,
// create a new one
mapView = new MKMapView(RectangleF.Empty);
}