public override void ViewDidLoad() { base.ViewDidLoad(); LoadingIndicator.Center = View.Center; LoadingIndicator.StartAnimating(); WebView.ScalesPageToFit = true; WebView.ContentMode = UIViewContentMode.ScaleAspectFit; WebView.LoadFinished += WebViewLoadFinished; if (NetworkStatus.IsDataConnectionAvailable()) { WebView.LoadRequest(new NSUrlRequest(new NSUrl(Uri))); WebView.SizeToFit(); } else { // note this this will thorw a native exception if the cache web page does not exist. // cannot find a work around at the moment WebView.LoadRequest(new NSUrlRequest(new NSUrl(Uri), NSUrlRequestCachePolicy.ReturnCacheDataDoNotLoad, 60)); WebView.SizeToFit(); } WebView.Frame = View.Bounds; }
private void HandleOffline() { if (!NetworkStatus.IsDataConnectionAvailable()) { var okAlertController = UIAlertController.Create("Info", "You are currently offline. Only displaying cached contents", UIAlertControllerStyle.Alert); okAlertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null)); PresentViewController(okAlertController, true, null); } }