Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Added guard code to iOS content page ViewDidLayoutSubviews
Browse files Browse the repository at this point in the history
Protected against race condition where ViewDidLayoutSubviews is called
before the XF NativeView property has been initialized. Also added
null-conditional checks to XFGlossGradientLayer’s GetGradientLayer
method.
  • Loading branch information
Tommy Baggett authored and Tommy Baggett committed Dec 13, 2016
1 parent 36eca57 commit 274a2b4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions XFGloss.iOS/Renderers/XFGlossContentPageRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,13 @@ protected override void Dispose(bool disposing)
/// </summary>
public override void ViewDidLayoutSubviews()
{
var layer = XFGlossGradientLayer.GetGradientLayer(NativeView);
if (layer != null)
if (NativeView != null)
{
layer.Frame = new CGRect(CGPoint.Empty, NativeView.Frame.Size);
var layer = XFGlossGradientLayer.GetGradientLayer(NativeView);
if (layer != null)
{
layer.Frame = new CGRect(CGPoint.Empty, NativeView.Frame.Size);
}
}

base.ViewDidLayoutSubviews();
Expand Down
2 changes: 1 addition & 1 deletion XFGloss.iOS/Views/UIBackgroundGradientView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static public void RemoveGradientLayer(UIView view)
/// <param name="view">The native view that the gradient layer is expected to be attached to</param>
static public XFGlossGradientLayer GetGradientLayer(UIView view)
{
if (view.Layer.Sublayers != null && view.Layer.Sublayers.Length > 0 && view.Layer.Sublayers[0] is XFGlossGradientLayer)
if (view?.Layer?.Sublayers != null && view.Layer.Sublayers.Length > 0 && view.Layer.Sublayers[0] is XFGlossGradientLayer)
{
return view.Layer.Sublayers[0] as XFGlossGradientLayer;
}
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1.0.4.{build}
version: 1.0.5.{build}
pull_requests:
do_not_increment_build_number: true
branches:
Expand Down

0 comments on commit 274a2b4

Please sign in to comment.