Hi,
I've a little Web Page view that as an overlay activity indicator, both defined on Forms level. In order to turn the indicator on and off, I use the custom renderer, see below.
It worked pretty nice with the previous forms version(s). Now when I pushAsync this page-no matter if animated or not, wrapped into Device.BeginInvocation or not--the page will not be pushed. No exception so far. As soon as I remove the event handler assignments it works again--however without the activity control. If at least one, empty event handler is there it doesn't get pushed.
Regardless the 1.4.2.6359 issue, is there any comment as such, maybe it's kinda Bad style and you know a better way?
Thx,
Ekki
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using Xamarin.Social;
[assembly:ExportRenderer(typeof(SthApp.Pages.WebViewPage), typeof(SthApp.iOS.WebViewPageRenderer))]
namespace SthApp.iOS
{
public class WebViewPageRenderer: PageRenderer
{
bool initialized = false;
public WebViewPageRenderer()
{
}
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (this.initialized)
{
return;
}
if (this.View == null || this.View.Subviews == null || this.View.Subviews.Length < 1)
{
return;
}
var tLayout = this.View.Subviews.GetValue(0) as UIView;
foreach (var tView in tLayout.Subviews)
{
var tWebView = tView as UIWebView;
if (tWebView != null)
{
tWebView.ScalesPageToFit = true;
tWebView.LoadStarted += (object sender, EventArgs e2) =>
{
this.SetActivity(tLayout, true);
};
tWebView.LoadFinished += (object sender, EventArgs e2) =>
{
this.SetActivity(tLayout, false);
};
this.initialized = true;
break;
}
}
}
void SetActivity(UIView super, bool start)
{
Device.BeginInvokeOnMainThread(() =>
{
foreach (var tView in super.Subviews)
{
var tRenderer = tView as
Xamarin.Forms.Platform.iOS.ViewRenderer<Xamarin.Forms.ActivityIndicator,
UIKit.UIActivityIndicatorView>;
if (tRenderer != null)
{
var tIndicator = tRenderer.Control;
tIndicator.Hidden = !start;
if (start)
{
tIndicator.StartAnimating();
}
else
{
tIndicator.StopAnimating();
}
break;
}
}
});
}
}
}