From 0e88e59af2ea36876d949999dbe850b1509ac629 Mon Sep 17 00:00:00 2001 From: Stuart McIlreavy Date: Mon, 5 Jun 2017 16:46:34 +0100 Subject: [PATCH] Updates to iOS samples issues reported in certification (#259) --- .../FeatureLayerQuery/FeatureLayerQuery.cs | 3 +- .../ServiceFeatureTableCache.cs | 14 +++--- .../ServiceFeatureTableManualCache.cs | 14 +++--- .../ServiceFeatureTableNoCache.cs | 14 +++--- .../AddGraphicsRenderer.cs | 13 ++--- .../IdentifyGraphics/IdentifyGraphics.cs | 10 ++-- .../SketchOnMap/SketchOnMap.cs | 13 +++-- .../ArcGISMapImageLayerUrl.cs | 16 +++--- .../ArcGISTiledLayerUrl.cs | 16 +++--- .../ArcGISVectorTiledLayerUrl.cs | 35 +++++++------ .../ChangeFeatureLayerRenderer.cs | 2 +- .../ChangeSublayerVisibility.cs | 26 +++++++--- .../CreateFeatureCollectionLayer.cs | 22 ++++---- .../FeatureCollectionLayerFromPortal.cs | 45 +++++++++-------- .../FeatureCollectionLayerFromQuery.cs | 23 +++++---- .../Layers/FeatureLayerUrl/FeatureLayerUrl.cs | 16 +++--- .../DisplayDeviceLocation.cs | 21 +++++--- .../Map/AccessLoadStatus/AccessLoadStatus.cs | 18 ++++--- .../Map/ChangeBasemap/ChangeBasemap.cs | 35 +++++++++---- .../Samples/Map/DisplayMap/DisplayMap.cs | 15 +++--- .../Map/ManageBookmarks/ManageBookmarks.cs | 17 ++++--- .../Map/OpenExistingMap/OpenExistingMap.cs | 3 +- .../Map/SearchPortalMaps/SearchPortalMaps.cs | 50 ++++++++++++++----- .../SetInitialMapArea/SetInitialMapArea.cs | 18 ++++--- .../SetInitialMapLocation.cs | 16 +++--- .../SetMapSpatialReference.cs | 18 ++++--- .../Map/SetMinMaxScale/SetMinMaxScale.cs | 16 +++--- .../ChangeViewpoint/ChangeViewpoint.cs | 33 +++++++----- .../DisplayDrawingStatus.cs | 34 +++++++++---- .../DisplayLayerViewState.cs | 25 ++++++---- .../MapView/MapRotation/MapRotation.cs | 45 ++++++++++------- .../MapView/ShowMagnifier/ShowMagnifier.cs | 16 +++--- .../MapView/TakeScreenshot/TakeScreenshot.cs | 33 ++++++------ .../RenderPictureMarkers.cs | 16 +++--- .../RenderSimpleMarkers.cs | 16 +++--- .../RenderUniqueValues/RenderUniqueValues.cs | 18 ++++--- .../UseDistanceCompositeSym.cs | 21 +++++--- 37 files changed, 475 insertions(+), 291 deletions(-) diff --git a/src/iOS/Xamarin.iOS/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.cs b/src/iOS/Xamarin.iOS/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.cs index 0f5a6f603d..71a3df4c3f 100644 --- a/src/iOS/Xamarin.iOS/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.cs +++ b/src/iOS/Xamarin.iOS/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.cs @@ -62,8 +62,7 @@ public override void ViewDidLoad() public override void ViewDidLayoutSubviews() { // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset + 80, View.Bounds.Width, View.Bounds.Height - yPageOffset - 80); + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); // Setup the visual frame for the text field used in query _queryTextView.Frame = new CoreGraphics.CGRect(0, yPageOffset, View.Bounds.Width, 40); diff --git a/src/iOS/Xamarin.iOS/Samples/Data/ServiceFeatureTableCache/ServiceFeatureTableCache.cs b/src/iOS/Xamarin.iOS/Samples/Data/ServiceFeatureTableCache/ServiceFeatureTableCache.cs index f5b82e493d..b738eb066a 100644 --- a/src/iOS/Xamarin.iOS/Samples/Data/ServiceFeatureTableCache/ServiceFeatureTableCache.cs +++ b/src/iOS/Xamarin.iOS/Samples/Data/ServiceFeatureTableCache/ServiceFeatureTableCache.cs @@ -31,15 +31,21 @@ public ServiceFeatureTableCache() Title = "Service feature table (cache)"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + } + private void Initialize() { // Create new Map with basemap @@ -75,10 +81,6 @@ private void Initialize() private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add MapView to the page View.AddSubviews(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/Data/ServiceFeatureTableManualCache/ServiceFeatureTableManualCache.cs b/src/iOS/Xamarin.iOS/Samples/Data/ServiceFeatureTableManualCache/ServiceFeatureTableManualCache.cs index 9dfc3094c8..b9e958470e 100644 --- a/src/iOS/Xamarin.iOS/Samples/Data/ServiceFeatureTableManualCache/ServiceFeatureTableManualCache.cs +++ b/src/iOS/Xamarin.iOS/Samples/Data/ServiceFeatureTableManualCache/ServiceFeatureTableManualCache.cs @@ -33,15 +33,21 @@ public ServiceFeatureTableManualCache() Title = "Service feature table (manual cache)"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + } + private void Initialize() { // Create new Map with basemap @@ -96,10 +102,6 @@ private async void OnLoadedPopulateData(object sender, Esri.ArcGISRuntime.LoadSt private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add MapView to the page View.AddSubviews(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/Data/ServiceFeatureTableNoCache/ServiceFeatureTableNoCache.cs b/src/iOS/Xamarin.iOS/Samples/Data/ServiceFeatureTableNoCache/ServiceFeatureTableNoCache.cs index 91a80416a6..336a3c7791 100644 --- a/src/iOS/Xamarin.iOS/Samples/Data/ServiceFeatureTableNoCache/ServiceFeatureTableNoCache.cs +++ b/src/iOS/Xamarin.iOS/Samples/Data/ServiceFeatureTableNoCache/ServiceFeatureTableNoCache.cs @@ -31,15 +31,21 @@ public ServiceFeatureTableNoCache() Title = "Service feature table (no cache)"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + } + private void Initialize() { // Create new Map with basemap @@ -76,10 +82,6 @@ private void Initialize() private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add MapView to the page View.AddSubviews(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/GraphicsOverlay/AddGraphicsRenderer/AddGraphicsRenderer.cs b/src/iOS/Xamarin.iOS/Samples/GraphicsOverlay/AddGraphicsRenderer/AddGraphicsRenderer.cs index d587690a43..a6f7322c65 100644 --- a/src/iOS/Xamarin.iOS/Samples/GraphicsOverlay/AddGraphicsRenderer/AddGraphicsRenderer.cs +++ b/src/iOS/Xamarin.iOS/Samples/GraphicsOverlay/AddGraphicsRenderer/AddGraphicsRenderer.cs @@ -32,14 +32,19 @@ public AddGraphicsRenderer() Title = "Add graphics (Renderer)"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + } private void Initialize() { @@ -114,10 +119,6 @@ private void OnViewpointChanged(object sender, EventArgs e) private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add MapView to the page View.AddSubviews(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/GraphicsOverlay/IdentifyGraphics/IdentifyGraphics.cs b/src/iOS/Xamarin.iOS/Samples/GraphicsOverlay/IdentifyGraphics/IdentifyGraphics.cs index e02db089ba..db93845ec4 100644 --- a/src/iOS/Xamarin.iOS/Samples/GraphicsOverlay/IdentifyGraphics/IdentifyGraphics.cs +++ b/src/iOS/Xamarin.iOS/Samples/GraphicsOverlay/IdentifyGraphics/IdentifyGraphics.cs @@ -45,6 +45,12 @@ public override void ViewDidLoad() Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + } + private void Initialize() { // Create a map with 'Imagery with Labels' basemap and an initial location @@ -117,10 +123,6 @@ private async void OnMapViewTapped(object sender, GeoViewInputEventArgs e) private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add MapView to the page View.AddSubviews(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/GraphicsOverlay/SketchOnMap/SketchOnMap.cs b/src/iOS/Xamarin.iOS/Samples/GraphicsOverlay/SketchOnMap/SketchOnMap.cs index 016289fc2f..e357871cbe 100644 --- a/src/iOS/Xamarin.iOS/Samples/GraphicsOverlay/SketchOnMap/SketchOnMap.cs +++ b/src/iOS/Xamarin.iOS/Samples/GraphicsOverlay/SketchOnMap/SketchOnMap.cs @@ -46,9 +46,9 @@ public SketchOnMap() Title = "Sketch on map"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI CreateLayout(); @@ -57,6 +57,12 @@ public override void ViewDidLayoutSubviews() Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + } + private void Initialize() { // Create a light gray canvas map @@ -89,9 +95,6 @@ private void CreateLayout() // Create a new MapView control _myMapView = new MapView(); - // Define the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect(0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add a segmented button control _segmentButton = new UISegmentedControl(); _segmentButton.BackgroundColor = UIColor.White; diff --git a/src/iOS/Xamarin.iOS/Samples/Layers/ArcGISMapImageLayerUrl/ArcGISMapImageLayerUrl.cs b/src/iOS/Xamarin.iOS/Samples/Layers/ArcGISMapImageLayerUrl/ArcGISMapImageLayerUrl.cs index fbf29af160..e58a00db9d 100644 --- a/src/iOS/Xamarin.iOS/Samples/Layers/ArcGISMapImageLayerUrl/ArcGISMapImageLayerUrl.cs +++ b/src/iOS/Xamarin.iOS/Samples/Layers/ArcGISMapImageLayerUrl/ArcGISMapImageLayerUrl.cs @@ -29,15 +29,23 @@ public ArcGISMapImageLayerUrl() Title = "ArcGIS map image layer (URL)"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create new Map @@ -59,10 +67,6 @@ private void Initialize() private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add MapView to the page View.AddSubviews(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/Layers/ArcGISTiledLayerUrl/ArcGISTiledLayerUrl.cs b/src/iOS/Xamarin.iOS/Samples/Layers/ArcGISTiledLayerUrl/ArcGISTiledLayerUrl.cs index 9e13f12790..1cc5fc6d27 100644 --- a/src/iOS/Xamarin.iOS/Samples/Layers/ArcGISTiledLayerUrl/ArcGISTiledLayerUrl.cs +++ b/src/iOS/Xamarin.iOS/Samples/Layers/ArcGISTiledLayerUrl/ArcGISTiledLayerUrl.cs @@ -29,15 +29,23 @@ public ArcGISTiledLayerUrl() Title = "ArcGIS tiled layer (URL)"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create new Map @@ -59,10 +67,6 @@ private void Initialize() private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add MapView to the page View.AddSubviews(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/Layers/ArcGISVectorTiledLayerUrl/ArcGISVectorTiledLayerUrl.cs b/src/iOS/Xamarin.iOS/Samples/Layers/ArcGISVectorTiledLayerUrl/ArcGISVectorTiledLayerUrl.cs index b50a4cf047..cd8c1a5972 100644 --- a/src/iOS/Xamarin.iOS/Samples/Layers/ArcGISVectorTiledLayerUrl/ArcGISVectorTiledLayerUrl.cs +++ b/src/iOS/Xamarin.iOS/Samples/Layers/ArcGISVectorTiledLayerUrl/ArcGISVectorTiledLayerUrl.cs @@ -21,6 +21,7 @@ public class ArcGISVectorTiledLayerUrl : UIViewController { // Create and hold reference to the used MapView private MapView _myMapView = new MapView(); + UIToolbar _toolbar; private string _navigationUrl = "https://www.arcgis.com/home/item.html?id=dcbbba0edf094eaa81af19298b9c6247"; private string _streetUrl = "https://www.arcgis.com/home/item.html?id=4e1133c28ac04cca97693cf336cd49ad"; @@ -41,16 +42,12 @@ public override void DidReceiveMemoryWarning() base.DidReceiveMemoryWarning(); } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); - - // Create a variable to hold the yOffset where the MapView control should start - var yOffset = 60; + base.ViewDidLoad(); // Create a new MapView control and provide its location coordinates on the frame - MapView myMapView = new MapView(); - myMapView.Frame = new CoreGraphics.CGRect(0, yOffset, View.Bounds.Width, View.Bounds.Height - yOffset); + _myMapView = new MapView(); // Create a new Map instance with the basemap Map myMap = new Map(SpatialReferences.WebMercator); @@ -61,7 +58,7 @@ public override void ViewDidLayoutSubviews() myMap.Basemap = new Basemap(_vectorTiledLayer); // Assign the Map to the MapView - myMapView.Map = myMap; + _myMapView.Map = myMap; // Create a segmented control to display buttons UISegmentedControl segmentControl = new UISegmentedControl(); @@ -104,7 +101,7 @@ public override void ViewDidLayoutSubviews() _vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri(_vectorTiledLayerUrl)); // Create new Map with basemap and assigning to the Mapviews Map - myMapView.Map = new Map(new Basemap(_vectorTiledLayer)); + _myMapView.Map = new Map(new Basemap(_vectorTiledLayer)); }; // Create a UIBarButtonItem where its view is the SegmentControl @@ -112,17 +109,27 @@ public override void ViewDidLayoutSubviews() barButtonItem.CustomView = segmentControl; // Create a toolbar on the bottom of the display - UIToolbar toolbar = new UIToolbar(); - toolbar.Frame = new CoreGraphics.CGRect(0, View.Bounds.Height - 40, View.Bounds.Width, View.Bounds.Height); - toolbar.AutosizesSubviews = true; + _toolbar = new UIToolbar(); + + _toolbar.AutosizesSubviews = true; // Add the bar button item to an array of UIBarButtonItems UIBarButtonItem[] barButtonItems = new UIBarButtonItem[] { barButtonItem }; // Add the UIBarButtonItems array to the toolbar - toolbar.SetItems(barButtonItems, true); + _toolbar.SetItems(barButtonItems, true); + + View.AddSubviews(_myMapView, _toolbar); + } - View.AddSubviews(myMapView, toolbar); + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + _toolbar.Frame = new CoreGraphics.CGRect(0, View.Bounds.Height - 40, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); } } } diff --git a/src/iOS/Xamarin.iOS/Samples/Layers/ChangeFeatureLayerRenderer/ChangeFeatureLayerRenderer.cs b/src/iOS/Xamarin.iOS/Samples/Layers/ChangeFeatureLayerRenderer/ChangeFeatureLayerRenderer.cs index dc580f6f10..63bd516c53 100644 --- a/src/iOS/Xamarin.iOS/Samples/Layers/ChangeFeatureLayerRenderer/ChangeFeatureLayerRenderer.cs +++ b/src/iOS/Xamarin.iOS/Samples/Layers/ChangeFeatureLayerRenderer/ChangeFeatureLayerRenderer.cs @@ -23,7 +23,7 @@ namespace ArcGISRuntimeXamarin.Samples.ChangeFeatureLayerRenderer public class ChangeFeatureLayerRenderer : UIViewController { // Create and hold reference to the used MapView - private MapView _myMapView = new MapView(); + private MapView _myMapView; //Create and hold reference to the feature layer private FeatureLayer _featureLayer; diff --git a/src/iOS/Xamarin.iOS/Samples/Layers/ChangeSublayerVisibility/ChangeSublayerVisibility.cs b/src/iOS/Xamarin.iOS/Samples/Layers/ChangeSublayerVisibility/ChangeSublayerVisibility.cs index f0a81664e1..0b603208f9 100644 --- a/src/iOS/Xamarin.iOS/Samples/Layers/ChangeSublayerVisibility/ChangeSublayerVisibility.cs +++ b/src/iOS/Xamarin.iOS/Samples/Layers/ChangeSublayerVisibility/ChangeSublayerVisibility.cs @@ -20,6 +20,12 @@ namespace ArcGISRuntimeXamarin.Samples.ChangeSublayerVisibility [Register("ChangeSublayerVisibility")] public class ChangeSublayerVisibility : UIViewController { + // Create a new MapView control and provide its location coordinates on the frame. + MapView myMapView = new MapView(); + + // Create a button to show sublayers + UIButton sublayersButton = new UIButton(UIButtonType.Custom); + public ChangeSublayerVisibility() { Title = "Change sublayer visibility"; @@ -43,16 +49,9 @@ public async override void ViewDidLoad() // Add the map image layer to the map's operational layers myMap.OperationalLayers.Add(mapImageLayer); - // Create a new MapView control and provide its location coordinates on the frame. - MapView myMapView = new MapView(); - myMapView.Frame = new CoreGraphics.CGRect(0, 60, View.Bounds.Width, View.Bounds.Height - 40); - // Assign the Map to the MapView myMapView.Map = myMap; - - // Create a button to show sublayers - UIButton sublayersButton = new UIButton(UIButtonType.Custom); - sublayersButton.Frame = new CoreGraphics.CGRect(0, myMapView.Bounds.Height, View.Bounds.Width, 40); + sublayersButton.BackgroundColor = UIColor.White; sublayersButton.SetTitle("Sublayers", UIControlState.Normal); sublayersButton.SetTitleColor(UIColor.Blue, UIControlState.Normal); @@ -75,6 +74,17 @@ public async override void ViewDidLoad() View.AddSubviews(myMapView, sublayersButton); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + myMapView.Frame = new CoreGraphics.CGRect(0, 60, View.Bounds.Width, View.Bounds.Height - 40); + + sublayersButton.Frame = new CoreGraphics.CGRect(0, myMapView.Bounds.Height, View.Bounds.Width, 40); + + base.ViewDidLayoutSubviews(); + } + + public override void DidReceiveMemoryWarning() { base.DidReceiveMemoryWarning(); diff --git a/src/iOS/Xamarin.iOS/Samples/Layers/CreateFeatureCollectionLayer/CreateFeatureCollectionLayer.cs b/src/iOS/Xamarin.iOS/Samples/Layers/CreateFeatureCollectionLayer/CreateFeatureCollectionLayer.cs index 002ed8350d..da05cf1ccf 100644 --- a/src/iOS/Xamarin.iOS/Samples/Layers/CreateFeatureCollectionLayer/CreateFeatureCollectionLayer.cs +++ b/src/iOS/Xamarin.iOS/Samples/Layers/CreateFeatureCollectionLayer/CreateFeatureCollectionLayer.cs @@ -23,6 +23,9 @@ namespace ArcGISRuntimeXamarin.Samples.CreateFeatureCollectionLayer [Register("CreateFeatureCollectionLayer")] public class CreateFeatureCollectionLayer : UIViewController { + // Constant holding offset where the MapView control should start + private const int yPageOffset = 60; + // Reference to the MapView used in the app private MapView _myMapView; @@ -31,9 +34,9 @@ public CreateFeatureCollectionLayer() Title = "Create a new feature collection layer"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the layout CreateLayout(); @@ -42,6 +45,14 @@ public override void ViewDidLayoutSubviews() Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { try @@ -160,16 +171,9 @@ private Renderer CreateRenderer(GeometryType rendererType) private void CreateLayout() { - // Define an offset from the top of the page (to account for the iOS status bar) - var yPageOffset = 60; - // Create a new MapView _myMapView = new MapView(); - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset + 40, View.Bounds.Width, View.Bounds.Height - yPageOffset - 40); - // Add the MapView to the page View.AddSubview(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/Layers/FeatureCollectionLayerFromPortal/FeatureCollectionLayerFromPortal.cs b/src/iOS/Xamarin.iOS/Samples/Layers/FeatureCollectionLayerFromPortal/FeatureCollectionLayerFromPortal.cs index b04e712875..0a90d30116 100644 --- a/src/iOS/Xamarin.iOS/Samples/Layers/FeatureCollectionLayerFromPortal/FeatureCollectionLayerFromPortal.cs +++ b/src/iOS/Xamarin.iOS/Samples/Layers/FeatureCollectionLayerFromPortal/FeatureCollectionLayerFromPortal.cs @@ -29,14 +29,16 @@ public class FeatureCollectionLayerFromPortal : UIViewController // Text field for specifying a portal item Id UITextField _collectionItemIdTextBox; + UIButton _addFeaturesButton; + public FeatureCollectionLayerFromPortal() { Title = "Create a feature collection layer from a portal item"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the layout CreateLayout(); @@ -45,6 +47,18 @@ public override void ViewDidLayoutSubviews() Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height - 50); + + _collectionItemIdTextBox.Frame = new CoreGraphics.CGRect(10, View.Bounds.Height - 50, View.Bounds.Width - 10, 20); + + _addFeaturesButton.Frame = new CoreGraphics.CGRect(0, View.Bounds.Height -30, View.Bounds.Width, 30); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Add a default value for the portal item Id @@ -114,38 +128,25 @@ private void CreateLayout() // Define an offset from the top of the page (to account for the iOS status bar) var yPageOffset = 60; - // Define the bottom of the map view (accommodate for additional controls below) - var bottom = appViewHeight - yPageOffset - 80; // Create a new MapView _myMapView = new MapView(); - // Setup the visual frame for the MapView - var mapViewFrame = new CoreGraphics.CGRect(0, yPageOffset, appViewWidth, bottom); - _myMapView.Frame = mapViewFrame; - // Create a text input for the portal item Id - bottom += 70; - var textInputFrame = new CoreGraphics.CGRect(10, bottom, appViewWidth - 10, 20); - _collectionItemIdTextBox = new UITextField(textInputFrame); + _collectionItemIdTextBox = new UITextField(); _collectionItemIdTextBox.BackgroundColor = UIColor.LightGray; // Create a button for adding features from a portal item - bottom += 30; - var buttonFrame = new CoreGraphics.CGRect(0, bottom, appViewWidth, 30); - UIButton addFeaturesButton = new UIButton(UIButtonType.Custom) - { - Frame = buttonFrame, - BackgroundColor = UIColor.White - }; - addFeaturesButton.SetTitle("Add from portal item", UIControlState.Normal); - addFeaturesButton.SetTitleColor(UIColor.Blue, UIControlState.Normal); + _addFeaturesButton = new UIButton(UIButtonType.Custom); + _addFeaturesButton.SetTitle("Add from portal item", UIControlState.Normal); + _addFeaturesButton.SetTitleColor(UIColor.Blue, UIControlState.Normal); + _addFeaturesButton.BackgroundColor = UIColor.White; // Assign a click handler to the UIButton - addFeaturesButton.TouchUpInside += OpenPortalFeatureCollectionClick; + _addFeaturesButton.TouchUpInside += OpenPortalFeatureCollectionClick; // Add the MapView, UITextField, and UIButton to the page - View.AddSubviews(_myMapView, _collectionItemIdTextBox, addFeaturesButton); + View.AddSubviews(_myMapView, _collectionItemIdTextBox, _addFeaturesButton); View.BackgroundColor = UIColor.White; } } diff --git a/src/iOS/Xamarin.iOS/Samples/Layers/FeatureCollectionLayerFromQuery/FeatureCollectionLayerFromQuery.cs b/src/iOS/Xamarin.iOS/Samples/Layers/FeatureCollectionLayerFromQuery/FeatureCollectionLayerFromQuery.cs index 344bb4392a..788052a381 100644 --- a/src/iOS/Xamarin.iOS/Samples/Layers/FeatureCollectionLayerFromQuery/FeatureCollectionLayerFromQuery.cs +++ b/src/iOS/Xamarin.iOS/Samples/Layers/FeatureCollectionLayerFromQuery/FeatureCollectionLayerFromQuery.cs @@ -22,6 +22,10 @@ public class FeatureCollectionLayerFromQuery : UIViewController // Reference to the MapView used in the app private MapView _myMapView; + // Define an offset from the top of the page (to account for the iOS status bar) + int yPageOffset = 60; + + // URL for a feature service layer to query private const string FeatureLayerUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0"; @@ -30,9 +34,9 @@ public FeatureCollectionLayerFromQuery() Title = "Add a query result as a feature collection layer"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the layout CreateLayout(); @@ -41,6 +45,14 @@ public override void ViewDidLayoutSubviews() Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { try @@ -85,16 +97,9 @@ private async void GetFeaturesFromQuery() private void CreateLayout() { - // Define an offset from the top of the page (to account for the iOS status bar) - var yPageOffset = 60; - // Create a new MapView _myMapView = new MapView(); - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset + 40, View.Bounds.Width, View.Bounds.Height - yPageOffset - 40); - // Add the MapView the page View.AddSubview(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/Layers/FeatureLayerUrl/FeatureLayerUrl.cs b/src/iOS/Xamarin.iOS/Samples/Layers/FeatureLayerUrl/FeatureLayerUrl.cs index b10ec94efb..dbd4cc2f9e 100644 --- a/src/iOS/Xamarin.iOS/Samples/Layers/FeatureLayerUrl/FeatureLayerUrl.cs +++ b/src/iOS/Xamarin.iOS/Samples/Layers/FeatureLayerUrl/FeatureLayerUrl.cs @@ -30,15 +30,23 @@ public FeatureLayerUrl() Title = "Feature layer (feature service)"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create new Map with basemap @@ -65,10 +73,6 @@ private void Initialize() private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add MapView to the page View.AddSubviews(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/Location/DisplayDeviceLocation/DisplayDeviceLocation.cs b/src/iOS/Xamarin.iOS/Samples/Location/DisplayDeviceLocation/DisplayDeviceLocation.cs index 25e6c9a9cb..0cfbe8a092 100644 --- a/src/iOS/Xamarin.iOS/Samples/Location/DisplayDeviceLocation/DisplayDeviceLocation.cs +++ b/src/iOS/Xamarin.iOS/Samples/Location/DisplayDeviceLocation/DisplayDeviceLocation.cs @@ -29,15 +29,26 @@ public DisplayDeviceLocation() Title = "Display Device Location"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView = new MapView() + { + Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height) + }; + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create new Map with basemap @@ -110,12 +121,6 @@ private void OnStartButtonClicked(object sender, EventArgs e) private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView = new MapView() - { - Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height) - }; - // Create a button to start the location var startButton = new UIBarButtonItem() { Title = "Start", Style = UIBarButtonItemStyle.Plain }; startButton.Clicked += OnStartButtonClicked; diff --git a/src/iOS/Xamarin.iOS/Samples/Map/AccessLoadStatus/AccessLoadStatus.cs b/src/iOS/Xamarin.iOS/Samples/Map/AccessLoadStatus/AccessLoadStatus.cs index d90165e1d0..6687f6b2eb 100644 --- a/src/iOS/Xamarin.iOS/Samples/Map/AccessLoadStatus/AccessLoadStatus.cs +++ b/src/iOS/Xamarin.iOS/Samples/Map/AccessLoadStatus/AccessLoadStatus.cs @@ -32,15 +32,23 @@ public AccessLoadStatus() Title = "Access load status"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create new Map with basemap @@ -73,11 +81,7 @@ private void CreateLayout() Frame = new CoreGraphics.CGRect( 0, yPageOffset, View.Bounds.Width, 40) }; - - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset + 40, View.Bounds.Width, View.Bounds.Height - yPageOffset - 40); - + // Add MapView to the page View.AddSubviews(_myMapView, _loadStatusTextView); } diff --git a/src/iOS/Xamarin.iOS/Samples/Map/ChangeBasemap/ChangeBasemap.cs b/src/iOS/Xamarin.iOS/Samples/Map/ChangeBasemap/ChangeBasemap.cs index 4577342155..67198f7609 100644 --- a/src/iOS/Xamarin.iOS/Samples/Map/ChangeBasemap/ChangeBasemap.cs +++ b/src/iOS/Xamarin.iOS/Samples/Map/ChangeBasemap/ChangeBasemap.cs @@ -18,6 +18,13 @@ namespace ArcGISRuntimeXamarin.Samples.ChangeBasemap [Register("ChangeBasemap")] public class ChangeBasemap : UIViewController { + + // Create a variable to hold the yOffset where the MapView control should start + int _yOffset = 60; + + MapView _myMapView; + + public ChangeBasemap() { Title = "Change basemap"; @@ -29,23 +36,23 @@ public override void DidReceiveMemoryWarning() base.DidReceiveMemoryWarning(); } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create a variable to hold the yOffset where the MapView control should start var yOffset = 60; // Create a new MapView control and provide its location coordinates on the frame - MapView myMapView = new MapView(); - myMapView.Frame = new CoreGraphics.CGRect(0, yOffset, View.Bounds.Width, View.Bounds.Height - yOffset); + _myMapView = new MapView(); + _myMapView.Frame = new CoreGraphics.CGRect(0, yOffset, View.Bounds.Width, View.Bounds.Height - yOffset); // Create a new Map instance with the basemap Map myMap = new Map(SpatialReferences.WebMercator); myMap.Basemap = Basemap.CreateTopographic(); // Assign the Map to the MapView - myMapView.Map = myMap; + _myMapView.Map = myMap; // Create a segmented control to display buttons UISegmentedControl segmentControl = new UISegmentedControl(); @@ -66,25 +73,25 @@ public override void ViewDidLayoutSubviews() case 0: // Set the basemap to Topographic - myMapView.Map.Basemap = Basemap.CreateTopographic(); + _myMapView.Map.Basemap = Basemap.CreateTopographic(); break; case 1: // Set the basemap to Streets - myMapView.Map.Basemap = Basemap.CreateStreets(); + _myMapView.Map.Basemap = Basemap.CreateStreets(); break; case 2: // Set the basemap to Imagery - myMapView.Map.Basemap = Basemap.CreateImagery(); + _myMapView.Map.Basemap = Basemap.CreateImagery(); break; case 3: // Set the basemap to Oceans - myMapView.Map.Basemap = Basemap.CreateOceans(); + _myMapView.Map.Basemap = Basemap.CreateOceans(); break; } }; @@ -104,7 +111,15 @@ public override void ViewDidLayoutSubviews() // Add the UIBarButtonItems array to the toolbar toolbar.SetItems(barButtonItems, true); - View.AddSubviews(myMapView, toolbar); + View.AddSubviews(_myMapView, toolbar); + } + + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); } } } \ No newline at end of file diff --git a/src/iOS/Xamarin.iOS/Samples/Map/DisplayMap/DisplayMap.cs b/src/iOS/Xamarin.iOS/Samples/Map/DisplayMap/DisplayMap.cs index 559134016a..1e4e9ae9bb 100644 --- a/src/iOS/Xamarin.iOS/Samples/Map/DisplayMap/DisplayMap.cs +++ b/src/iOS/Xamarin.iOS/Samples/Map/DisplayMap/DisplayMap.cs @@ -39,20 +39,23 @@ private void Initialize() private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add MapView to the page View.AddSubviews(_myMapView); } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { CreateLayout(); Initialize(); + base.ViewDidLoad(); + } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + base.ViewDidLayoutSubviews(); } -} + } } \ No newline at end of file diff --git a/src/iOS/Xamarin.iOS/Samples/Map/ManageBookmarks/ManageBookmarks.cs b/src/iOS/Xamarin.iOS/Samples/Map/ManageBookmarks/ManageBookmarks.cs index f37a34a0b4..ea6782d91c 100644 --- a/src/iOS/Xamarin.iOS/Samples/Map/ManageBookmarks/ManageBookmarks.cs +++ b/src/iOS/Xamarin.iOS/Samples/Map/ManageBookmarks/ManageBookmarks.cs @@ -27,15 +27,23 @@ public ManageBookmarks() Title = "Manage bookmarks"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create new Map with basemap @@ -153,10 +161,7 @@ private void OnShowBookmarksButtonClicked(object sender, EventArgs e) private void CreateLayout() { // Setup the visual frame for the MapView - _myMapView = new MapView() - { - Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height) - }; + _myMapView = new MapView(); // Create a bookmark button to show existing bookmarks var showBookmarksButton = new UIBarButtonItem() { Title = "Bookmarks", Style = UIBarButtonItemStyle.Plain }; diff --git a/src/iOS/Xamarin.iOS/Samples/Map/OpenExistingMap/OpenExistingMap.cs b/src/iOS/Xamarin.iOS/Samples/Map/OpenExistingMap/OpenExistingMap.cs index ff7ee74344..aeb33470eb 100644 --- a/src/iOS/Xamarin.iOS/Samples/Map/OpenExistingMap/OpenExistingMap.cs +++ b/src/iOS/Xamarin.iOS/Samples/Map/OpenExistingMap/OpenExistingMap.cs @@ -89,8 +89,7 @@ private void OnMapsButtonTouch(object sender, EventArgs e) private void CreateLayout() { // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); // Add a button at the bottom to show webmap choices UIButton mapsButton = new UIButton(UIButtonType.Custom) diff --git a/src/iOS/Xamarin.iOS/Samples/Map/SearchPortalMaps/SearchPortalMaps.cs b/src/iOS/Xamarin.iOS/Samples/Map/SearchPortalMaps/SearchPortalMaps.cs index 5c713cdb84..9ce240c4d5 100644 --- a/src/iOS/Xamarin.iOS/Samples/Map/SearchPortalMaps/SearchPortalMaps.cs +++ b/src/iOS/Xamarin.iOS/Samples/Map/SearchPortalMaps/SearchPortalMaps.cs @@ -30,6 +30,8 @@ public class SearchPortalMaps : UIViewController, IOAuthAuthorizeHandler // Create and hold reference to the used MapView private MapView _myMapView = new MapView(); + UISegmentedControl _segmentButton; + // Use a TaskCompletionSource to track the completion of the authorization private TaskCompletionSource> _taskCompletionSource; @@ -65,6 +67,34 @@ public override void ViewDidLoad() Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + if (_searchMapsUI != null) + { + _searchMapsUI.Bounds = new CoreGraphics.CGRect(0, yPageOffset, View.Bounds.Width, View.Bounds.Height); + _searchMapsUI.Frame = new CoreGraphics.CGRect(0, yPageOffset, View.Bounds.Width, View.Bounds.Height); + _searchMapsUI.Center = View.Center; + } + + + if (_oauthInfoUI != null) + { + _oauthInfoUI.Bounds = new CoreGraphics.CGRect(0, yPageOffset, View.Bounds.Width, View.Bounds.Height); + _oauthInfoUI.Frame = new CoreGraphics.CGRect(0, yPageOffset, View.Bounds.Width, View.Bounds.Height); + _oauthInfoUI.Center = View.Center; + } + + + _segmentButton.Frame = new CoreGraphics.CGRect(0, _myMapView.Bounds.Height, View.Bounds.Width, 30); + + + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create a new Map instance to display by default @@ -82,7 +112,7 @@ private void ShowOAuthPropsUI() if (_oauthInfoUI != null) { return; } // Create a view to show entry controls over the map view - var ovBounds = new CoreGraphics.CGRect(0, 60, View.Bounds.Width, View.Bounds.Height - 60); + var ovBounds = new CoreGraphics.CGRect(0, yPageOffset, View.Bounds.Width, View.Bounds.Height); ; _oauthInfoUI = new OAuthPropsDialogOverlay(ovBounds, 0.75f, UIColor.White, _appClientId, _oAuthRedirectUrl); // Handle the OnOAuthPropsInfoEntered event to get the info entered by the user @@ -111,21 +141,17 @@ private void ShowOAuthPropsUI() private void CreateLayout() { - // Define the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect(0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add a segmented button control - var segmentButton = new UISegmentedControl(); - segmentButton.BackgroundColor = UIColor.White; - segmentButton.Frame = new CoreGraphics.CGRect(0, _myMapView.Bounds.Height, View.Bounds.Width, 30); - segmentButton.InsertSegment("Search Maps", 0, false); - segmentButton.InsertSegment("My Maps", 1, false); + _segmentButton = new UISegmentedControl(); + _segmentButton.BackgroundColor = UIColor.White; + _segmentButton.InsertSegment("Search Maps", 0, false); + _segmentButton.InsertSegment("My Maps", 1, false); // Handle the "click" for each segment (new segment is selected) - segmentButton.ValueChanged += SegmentButtonClicked; + _segmentButton.ValueChanged += SegmentButtonClicked; // Add the MapView and segmented button to the page - View.AddSubviews(_myMapView, segmentButton); + View.AddSubviews(_myMapView, _segmentButton); } private void SegmentButtonClicked(object sender, EventArgs e) @@ -157,7 +183,7 @@ private void ShowSearchMapUI() if (_searchMapsUI != null) { return; } // Create a view to show map item info entry controls over the map view - var ovBounds = new CoreGraphics.CGRect(0, 60, View.Bounds.Width, View.Bounds.Height - 60); + var ovBounds = new CoreGraphics.CGRect(0, yPageOffset, View.Bounds.Width, View.Bounds.Height); _searchMapsUI = new SearchMapsDialogOverlay(ovBounds, 0.75f, UIColor.White); // Handle the OnSearchMapsTextEntered event to get the info entered by the user diff --git a/src/iOS/Xamarin.iOS/Samples/Map/SetInitialMapArea/SetInitialMapArea.cs b/src/iOS/Xamarin.iOS/Samples/Map/SetInitialMapArea/SetInitialMapArea.cs index bdeafc5e02..1891d33561 100644 --- a/src/iOS/Xamarin.iOS/Samples/Map/SetInitialMapArea/SetInitialMapArea.cs +++ b/src/iOS/Xamarin.iOS/Samples/Map/SetInitialMapArea/SetInitialMapArea.cs @@ -29,15 +29,23 @@ public SetInitialMapArea() Title = "Set initial map area"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create new Map with basemap @@ -54,11 +62,7 @@ private void Initialize() } private void CreateLayout() - { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - + { // Add MapView to the page View.AddSubviews(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/Map/SetInitialMapLocation/SetInitialMapLocation.cs b/src/iOS/Xamarin.iOS/Samples/Map/SetInitialMapLocation/SetInitialMapLocation.cs index 44636c3966..7aca186337 100644 --- a/src/iOS/Xamarin.iOS/Samples/Map/SetInitialMapLocation/SetInitialMapLocation.cs +++ b/src/iOS/Xamarin.iOS/Samples/Map/SetInitialMapLocation/SetInitialMapLocation.cs @@ -28,15 +28,23 @@ public SetInitialMapLocation() Title = "Set initial map location"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create a map with 'Imagery with Labels' basemap and an initial location @@ -48,10 +56,6 @@ private void Initialize() private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add MapView to the page View.AddSubviews(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/Map/SetMapSpatialReference/SetMapSpatialReference.cs b/src/iOS/Xamarin.iOS/Samples/Map/SetMapSpatialReference/SetMapSpatialReference.cs index b43d7cb81f..a7991e11ea 100644 --- a/src/iOS/Xamarin.iOS/Samples/Map/SetMapSpatialReference/SetMapSpatialReference.cs +++ b/src/iOS/Xamarin.iOS/Samples/Map/SetMapSpatialReference/SetMapSpatialReference.cs @@ -30,15 +30,23 @@ public SetMapSpatialReference() Title = "Set map spatial reference"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create new Map using spatial reference as world bonne (54024) @@ -59,11 +67,7 @@ private void Initialize() private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - - // Add MapView to the page + // Add MapView to the page View.AddSubviews(_myMapView); } } diff --git a/src/iOS/Xamarin.iOS/Samples/Map/SetMinMaxScale/SetMinMaxScale.cs b/src/iOS/Xamarin.iOS/Samples/Map/SetMinMaxScale/SetMinMaxScale.cs index 3cc200d491..f3d16fac47 100644 --- a/src/iOS/Xamarin.iOS/Samples/Map/SetMinMaxScale/SetMinMaxScale.cs +++ b/src/iOS/Xamarin.iOS/Samples/Map/SetMinMaxScale/SetMinMaxScale.cs @@ -29,15 +29,23 @@ public SetMinMaxScale() Title = "Set Min & Max Scale"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create new Map with Streets basemap @@ -65,10 +73,6 @@ private void Initialize() private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add MapView to the page View.AddSubviews(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/MapView/ChangeViewpoint/ChangeViewpoint.cs b/src/iOS/Xamarin.iOS/Samples/MapView/ChangeViewpoint/ChangeViewpoint.cs index a777cc2e33..90b2594ad6 100644 --- a/src/iOS/Xamarin.iOS/Samples/MapView/ChangeViewpoint/ChangeViewpoint.cs +++ b/src/iOS/Xamarin.iOS/Samples/MapView/ChangeViewpoint/ChangeViewpoint.cs @@ -24,6 +24,8 @@ public class ChangeViewpoint : UIViewController // Constant holding offset where the MapView control should start private const int yPageOffset = 60; + private UIButton _viewpointsButton; + // Create and hold reference to the used MapView private MapView _myMapView = new MapView(); @@ -66,15 +68,26 @@ public ChangeViewpoint() Title = "Change viewpoint"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + // Setup the visual frame for the Button + _viewpointsButton.Frame = new CoreGraphics.CGRect(0, View.Bounds.Height - 40, View.Bounds.Width, 40); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create new Map with basemap and initial location @@ -124,25 +137,19 @@ await _myMapView.SetViewpointAsync( private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add a button at the bottom to show viewpoint choices - UIButton viewpointsButton = new UIButton(UIButtonType.Custom) + _viewpointsButton = new UIButton(UIButtonType.Custom) { - Frame = new CoreGraphics.CGRect( - 0, View.Bounds.Height - 40, View.Bounds.Width, 40), BackgroundColor = UIColor.White }; // Create button to show map options - viewpointsButton.SetTitle("Viewpoints", UIControlState.Normal); - viewpointsButton.SetTitleColor(UIColor.Blue, UIControlState.Normal); - viewpointsButton.TouchUpInside += OnViewpointsButtonTouch; + _viewpointsButton.SetTitle("Viewpoints", UIControlState.Normal); + _viewpointsButton.SetTitleColor(UIColor.Blue, UIControlState.Normal); + _viewpointsButton.TouchUpInside += OnViewpointsButtonTouch; // Add MapView to the page - View.AddSubviews(_myMapView, viewpointsButton); + View.AddSubviews(_myMapView, _viewpointsButton); } } } \ No newline at end of file diff --git a/src/iOS/Xamarin.iOS/Samples/MapView/DisplayDrawingStatus/DisplayDrawingStatus.cs b/src/iOS/Xamarin.iOS/Samples/MapView/DisplayDrawingStatus/DisplayDrawingStatus.cs index d999874e9d..70a1c26ef3 100644 --- a/src/iOS/Xamarin.iOS/Samples/MapView/DisplayDrawingStatus/DisplayDrawingStatus.cs +++ b/src/iOS/Xamarin.iOS/Samples/MapView/DisplayDrawingStatus/DisplayDrawingStatus.cs @@ -26,6 +26,8 @@ public class DisplayDrawingStatus : UIViewController // Create and hold reference to the used MapView private MapView _myMapView; + private UIToolbar _toolbar; + // Control to show the drawing status UIActivityIndicatorView _activityIndicator; @@ -34,15 +36,28 @@ public DisplayDrawingStatus() Title = "Display drawing status"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, yPageOffset, View.Bounds.Width, View.Bounds.Height); + + // Setup the visual frame for the tool bar + _toolbar.Frame = new CoreGraphics.CGRect(0, View.Bounds.Height - 30, View.Bounds.Width, 30); + + _activityIndicator.Frame = new CoreGraphics.CGRect(0, 0, _toolbar.Bounds.Width, _toolbar.Bounds.Height); + + base.ViewDidLayoutSubviews(); + } + private async void Initialize() { // Create new Map with basemap @@ -89,16 +104,13 @@ private void CreateLayout() { // Create a new MapView control and provide its location coordinates on the frame _myMapView = new MapView(); - _myMapView.Frame = new CoreGraphics.CGRect(0, yPageOffset, View.Bounds.Width, View.Bounds.Height - 30); - + // Create a toolbar on the bottom of the display - UIToolbar toolbar = new UIToolbar(); - toolbar.Frame = new CoreGraphics.CGRect(0, _myMapView.Bounds.Height, View.Bounds.Width, 30); - + _toolbar = new UIToolbar(); + // Create an activity indicator _activityIndicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray); - _activityIndicator.Frame = new CoreGraphics.CGRect(0, 0, toolbar.Bounds.Width, toolbar.Bounds.Height); - + // Create a UIBarButtonItem to show the activity indicator UIBarButtonItem indicatorButton = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace); indicatorButton.CustomView = _activityIndicator; @@ -107,10 +119,10 @@ private void CreateLayout() var barButtonItems = new UIBarButtonItem[] { indicatorButton }; // Add the UIBarButtonItems to the toolbar - toolbar.SetItems(barButtonItems, true); + _toolbar.SetItems(barButtonItems, true); // Add the MapView to the Subview - View.AddSubviews(_myMapView, toolbar); + View.AddSubviews(_myMapView, _toolbar); } } } \ No newline at end of file diff --git a/src/iOS/Xamarin.iOS/Samples/MapView/DisplayLayerViewState/DisplayLayerViewState.cs b/src/iOS/Xamarin.iOS/Samples/MapView/DisplayLayerViewState/DisplayLayerViewState.cs index c8d7532ef8..478357ebba 100644 --- a/src/iOS/Xamarin.iOS/Samples/MapView/DisplayLayerViewState/DisplayLayerViewState.cs +++ b/src/iOS/Xamarin.iOS/Samples/MapView/DisplayLayerViewState/DisplayLayerViewState.cs @@ -35,13 +35,23 @@ public DisplayLayerViewState() Title = "Display Layer View State"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height -120); + + _tableView.Frame = new CoreGraphics.CGRect(0, _myMapView.Frame.Height, View.Bounds.Width, 120); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create new Map @@ -126,16 +136,13 @@ private void CreateLayout() stackView.Distribution = UIStackViewDistribution.FillProportionally; stackView.BackgroundColor = UIColor.Gray; - // Setup the visual frame for the MapView - _myMapView = new MapView() - { - Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height-80) - }; - + _myMapView = new MapView(); + stackView.AddArrangedSubview(_myMapView); // Create a tableview for displaying layer view status for each layer - _tableView = new UITableView(new CoreGraphics.CGRect(0, _myMapView.Frame.Height, View.Bounds.Width, height)); + _tableView = new UITableView(); + stackView.AddArrangedSubview(_tableView); // Add MapView to the page diff --git a/src/iOS/Xamarin.iOS/Samples/MapView/MapRotation/MapRotation.cs b/src/iOS/Xamarin.iOS/Samples/MapView/MapRotation/MapRotation.cs index d932403c57..1bdf4767c9 100644 --- a/src/iOS/Xamarin.iOS/Samples/MapView/MapRotation/MapRotation.cs +++ b/src/iOS/Xamarin.iOS/Samples/MapView/MapRotation/MapRotation.cs @@ -18,45 +18,46 @@ namespace ArcGISRuntimeXamarin.Samples.MapRotation [Register("MapRotation")] public class MapRotation : UIViewController { + + private MapView _myMapView; + private int _yOffset = 60; + private UIToolbar _toolbar; + public MapRotation() { Title = "Map rotation"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); - - // Create a variable to hold the yOffset where the MapView control should start - var yOffset = 60; + base.ViewDidLoad(); // Create a new MapView control and provide its location coordinates on the frame - MapView myMapView = new MapView(); - myMapView.Frame = new CoreGraphics.CGRect(0, yOffset, View.Bounds.Width, View.Bounds.Height - yOffset); - + _myMapView = new MapView(); + // Create a new Map instance with the basemap var myBasemap = Basemap.CreateStreets(); Map myMap = new Map(myBasemap); // Assign the Map to the MapView - myMapView.Map = myMap; + _myMapView.Map = myMap; // Create a label to display the MapView rotation value UILabel rotationLabel = new UILabel(); rotationLabel.Frame = new CoreGraphics.CGRect(View.Bounds.Width - 60, 8, View.Bounds.Width, 24); - rotationLabel.Text = string.Format("{0:0}°", myMapView.MapRotation); + rotationLabel.Text = string.Format("{0:0}°", _myMapView.MapRotation); // Create a slider to control the MapView rotation UISlider rotationSlider = new UISlider() { MinValue = 0, MaxValue = 360, - Value = (float)myMapView.MapRotation + Value = (float)_myMapView.MapRotation }; rotationSlider.Frame = new CoreGraphics.CGRect(10, 8, View.Bounds.Width - 100, 24); rotationSlider.ValueChanged += (Object s, EventArgs e) => { - myMapView.SetViewpointRotationAsync(rotationSlider.Value); + _myMapView.SetViewpointRotationAsync(rotationSlider.Value); rotationLabel.Text = string.Format("{0:0}°", rotationSlider.Value); }; @@ -69,17 +70,27 @@ public override void ViewDidLayoutSubviews() barButtonLabel.CustomView = rotationLabel; // Create a toolbar on the bottom of the display - UIToolbar toolbar = new UIToolbar(); - toolbar.Frame = new CoreGraphics.CGRect(0, View.Bounds.Height - 40, View.Bounds.Width, View.Bounds.Height); - toolbar.AutosizesSubviews = true; + _toolbar = new UIToolbar(); + _toolbar.AutosizesSubviews = true; // Add the bar button items to an array of UIBarButtonItems UIBarButtonItem[] barButtonItems = new UIBarButtonItem[] { barButtonSlider, barButtonLabel }; // Add the UIBarButtonItems array to the toolbar - toolbar.SetItems(barButtonItems, true); + _toolbar.SetItems(barButtonItems, true); - View.AddSubviews(myMapView, toolbar); + View.AddSubviews(_myMapView, _toolbar); + } + + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + // Setup the visual frame for the Toolbar + _toolbar.Frame = new CoreGraphics.CGRect(0, View.Bounds.Height - 40, View.Bounds.Width, View.Bounds.Height); + + + base.ViewDidLayoutSubviews(); } } } \ No newline at end of file diff --git a/src/iOS/Xamarin.iOS/Samples/MapView/ShowMagnifier/ShowMagnifier.cs b/src/iOS/Xamarin.iOS/Samples/MapView/ShowMagnifier/ShowMagnifier.cs index d1b4af20a5..053f610771 100644 --- a/src/iOS/Xamarin.iOS/Samples/MapView/ShowMagnifier/ShowMagnifier.cs +++ b/src/iOS/Xamarin.iOS/Samples/MapView/ShowMagnifier/ShowMagnifier.cs @@ -28,15 +28,23 @@ public ShowMagnifier() Title = "Show magnifier"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create new Map with basemap and initial location @@ -51,10 +59,6 @@ private void Initialize() private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add MapView to the page View.AddSubviews(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/MapView/TakeScreenshot/TakeScreenshot.cs b/src/iOS/Xamarin.iOS/Samples/MapView/TakeScreenshot/TakeScreenshot.cs index 8982fc6bef..6078789a60 100644 --- a/src/iOS/Xamarin.iOS/Samples/MapView/TakeScreenshot/TakeScreenshot.cs +++ b/src/iOS/Xamarin.iOS/Samples/MapView/TakeScreenshot/TakeScreenshot.cs @@ -38,14 +38,26 @@ public TakeScreenshot() this.Title = "Take Screenshot"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + _overlayView.Frame = new CoreGraphics.CGRect(10, 80, _myMapView.Frame.Width - 20, _myMapView.Frame.Height - 75); + + _overlayImageView.Frame = new CoreGraphics.CGRect(0, 0, _overlayView.Frame.Width, _overlayView.Frame.Height); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create new Map with basemap @@ -73,11 +85,8 @@ private async void OnScreenshotButtonClicked(object sender, EventArgs e) private void CreateLayout() { // Setup the visual frame for the MapView - _myMapView = new MapView() - { - Frame = new CoreGraphics.CGRect(0, yPageOffset, View.Bounds.Width, View.Bounds.Height- yPageOffset) - }; - + _myMapView = new MapView(); + // Create a button to take the screenshot var screenshotButton = new UIBarButtonItem() { Title = "Screenshot", Style = UIBarButtonItemStyle.Plain }; screenshotButton.Clicked += OnScreenshotButtonClicked; @@ -96,16 +105,10 @@ private void CreateLayout() NavigationController.ToolbarHidden = false; // Add the new View as an overlayview - _overlayView = new UIView() - { - Frame = new CoreGraphics.CGRect(10, 80, _myMapView.Frame.Width-20, _myMapView.Frame.Height-75) - }; + _overlayView = new UIView(); // Create a new image view to hold the screenshot image - _overlayImageView = new UIImageView() - { - Frame = new CoreGraphics.CGRect(0, 0, _overlayView.Frame.Width, _overlayView.Frame.Height) - }; + _overlayImageView = new UIImageView(); _overlayImageView.Layer.BorderColor = UIColor.White.CGColor; _overlayImageView.Layer.BorderWidth = 2; diff --git a/src/iOS/Xamarin.iOS/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.cs b/src/iOS/Xamarin.iOS/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.cs index 0d7bc494d6..54de1ef8f1 100644 --- a/src/iOS/Xamarin.iOS/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.cs +++ b/src/iOS/Xamarin.iOS/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.cs @@ -34,14 +34,22 @@ public RenderPictureMarkers() Title = "Render picture markers"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); + } + private async void Initialize() { // Create new Map with basemap @@ -115,10 +123,6 @@ private async Task CreatePictureMarkerSymbolFromResources(GraphicsOverlay overla private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add MapView to the page View.AddSubviews(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.cs b/src/iOS/Xamarin.iOS/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.cs index 702bef14eb..2e5e67c11a 100644 --- a/src/iOS/Xamarin.iOS/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.cs +++ b/src/iOS/Xamarin.iOS/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.cs @@ -32,15 +32,23 @@ public RenderSimpleMarkers() Title = "Render simple markers"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create new Map with basemap @@ -77,10 +85,6 @@ private void Initialize() private void CreateLayout() { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - // Add MapView to the page View.AddSubviews(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/Symbology/RenderUniqueValues/RenderUniqueValues.cs b/src/iOS/Xamarin.iOS/Samples/Symbology/RenderUniqueValues/RenderUniqueValues.cs index 70bdd5c254..89761822c3 100644 --- a/src/iOS/Xamarin.iOS/Samples/Symbology/RenderUniqueValues/RenderUniqueValues.cs +++ b/src/iOS/Xamarin.iOS/Samples/Symbology/RenderUniqueValues/RenderUniqueValues.cs @@ -31,15 +31,23 @@ public RenderUniqueValues() Title = "Render unique values"; } - public override void ViewDidLayoutSubviews() + public override void ViewDidLoad() { - base.ViewDidLayoutSubviews(); + base.ViewDidLoad(); // Create the UI, setup the control references and execute initialization CreateLayout(); Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Setup the visual frame for the MapView + _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create new Map with basemap @@ -101,11 +109,7 @@ private void Initialize() } private void CreateLayout() - { - // Setup the visual frame for the MapView - _myMapView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - + { // Add MapView to the page View.AddSubviews(_myMapView); } diff --git a/src/iOS/Xamarin.iOS/Samples/Symbology/UseDistanceCompositeSym/UseDistanceCompositeSym.cs b/src/iOS/Xamarin.iOS/Samples/Symbology/UseDistanceCompositeSym/UseDistanceCompositeSym.cs index 312e73960b..37f559b599 100644 --- a/src/iOS/Xamarin.iOS/Samples/Symbology/UseDistanceCompositeSym/UseDistanceCompositeSym.cs +++ b/src/iOS/Xamarin.iOS/Samples/Symbology/UseDistanceCompositeSym/UseDistanceCompositeSym.cs @@ -40,6 +40,18 @@ public override void ViewDidLoad() Initialize(); } + public override void ViewDidLayoutSubviews() + { + // Define an offset from the top of the page (to account for the iOS status bar) + var yPageOffset = 60; + + // Setup the visual frame for the MapView + _mySceneView.Frame = new CoreGraphics.CGRect( + 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); + + base.ViewDidLayoutSubviews(); + } + private void Initialize() { // Create a new Scene with an imagery basemap @@ -98,14 +110,7 @@ private DistanceCompositeSceneSymbol CreateCompositeSymbol() } private void CreateLayout() - { - // Define an offset from the top of the page (to account for the iOS status bar) - var yPageOffset = 60; - - // Setup the visual frame for the MapView - _mySceneView.Frame = new CoreGraphics.CGRect( - 0, yPageOffset, View.Bounds.Width, View.Bounds.Height - yPageOffset); - + { // Add MapView to the page View.AddSubviews(_mySceneView); }