本文整理汇总了C#中UIWebView.LoadHtmlString方法的典型用法代码示例。如果您正苦于以下问题:C# UIWebView.LoadHtmlString方法的具体用法?C# UIWebView.LoadHtmlString怎么用?C# UIWebView.LoadHtmlString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIWebView
的用法示例。
在下文中一共展示了UIWebView.LoadHtmlString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: collectDevice
public static void collectDevice()
{
string SessionId = Conekta.DeviceFingerPrint ();
string PublicKey = Conekta.PublicKey;
string html = "<!DOCTYPE html><html><head></head><body style=\"background: blue;\">";
html += "<script type=\"text/javascript\" src=\"https://conektaapi.s3.amazonaws.com/v0.5.0/js/conekta.js\" data-conekta-public-key=\"" + PublicKey + "\" data-conekta-session-id=\"" + SessionId + "\"></script>";
html += "</body></html>";
string contentPath = Environment.CurrentDirectory;
#if __IOS__
UIWebView web = new UIWebView(new RectangleF(new PointF(0,0), new SizeF(0, 0)));
web.ScalesPageToFit = true;
web.LoadHtmlString(html, new NSUrl("https://conektaapi.s3.amazonaws.com/v0.5.0/js/conekta.js"));
Conekta._delegate.View.AddSubview(web);
#endif
#if __ANDROID__
WebView web_view = new WebView(Android.App.Application.Context);
web_view.Settings.JavaScriptEnabled = true;
web_view.Settings.AllowContentAccess = true;
web_view.Settings.DomStorageEnabled = true;
web_view.LoadDataWithBaseURL(Conekta.UriConektaJs, html, "text/html", "UTF-8", null);
#endif
}
示例2: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
var webFrame = UIScreen.MainScreen.ApplicationFrame;
_webView = new UIWebView(webFrame) {
BackgroundColor = UIColor.White,
ScalesPageToFit = true,
AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
};
_webView.LoadStarted += delegate {
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
};
_webView.LoadFinished += delegate {
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
};
_webView.LoadError += (webview, args) => {
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
_webView.LoadHtmlString (String.Format ("<html><center><font size=+5 color='red'>An error occurred:<br>{0}</font></center></html>", args.Error.LocalizedDescription), null);
};
View.AddSubview(_webView);
_webView.LoadRequest(new NSUrlRequest(new NSUrl(ViewModel.Uri)));
}
示例3: HtmlSelected
public static UIViewController HtmlSelected(ApiNode apiNode)
{
var vc = new UIViewController();
var webView = new UIWebView(UIScreen.MainScreen.Bounds)
{
BackgroundColor = UIColor.White,
ScalesPageToFit = false,
AutoresizingMask = UIViewAutoresizing.All
};
var html = apiNode["content"];
if (apiNode["contentNode"] != null)
{
html = apiNode[apiNode["contentNode"]];
}
if (html != null && !html.Contains("<html"))
{
html = String.Format("<html><head><link href=\"main-style.css\" rel=\"stylesheet\" type=\"text/css\" /></head><body><h1>{0}</h1>{1}</body><html>", apiNode.Title, html);
}
if (html != null)
webView.LoadHtmlString(html, new NSUrl("HtmlContent/", true));
vc.NavigationItem.Title = apiNode.Title;
vc.View.AutosizesSubviews = true;
vc.View.AddSubview(webView);
return vc;
}
示例4: OnLoadFailed
private void OnLoadFailed(UIWebView webView, NSError error)
{
// Report the error inside the web view.
var localizedErrorMessage = "An error occured:".Localize ();
var errorHTML = string.Format ("<!doctype html><html><body><div style=\"width: 100%%; text-align: center; font-size: 36pt;\">{0} {1}</div></body></html>", localizedErrorMessage, error.Description);
webView.LoadHtmlString (errorHTML, null);
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
}
示例5: TriumphatorWebViewController
public TriumphatorWebViewController () : base()
{
Title = Locale.GetText ("Speisekarte");
_webView = new UIWebView ();
_webView.ScalesPageToFit = true;
//_webView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
_webView.LoadError += (webview, args) => {
if (_webView != null)
_webView.LoadHtmlString (
String.Format ("<html><center><font color='red'>{0}:<br>{1}</font></center></html>",
"An error occurred:", args.Error.LocalizedDescription), null);
};
}
示例6: ViewDidLoad
public override void ViewDidLoad ()
{
Title = "Web";
NavigationController.NavigationBar.Translucent = false;
var webFrame = UIScreen.MainScreen.ApplicationFrame;
webFrame.Y += 25f;
webFrame.Height -= 40f;
web = new UIWebView (webFrame) {
BackgroundColor = UIColor.White,
ScalesPageToFit = true,
AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
};
web.LoadStarted += delegate {
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
};
web.LoadFinished += delegate {
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
};
web.LoadError += (webview, args) => {
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
web.LoadHtmlString (String.Format ("<html><center><font size=+5 color='red'>An error occurred:<br>{0}</font></center></html>", args.Error.LocalizedDescription), null);
};
View.AddSubview (web);
// Delegate = new
var urlField = new UITextField (new CGRect (20f, 10f, View.Bounds.Width - (20f * 2f), 30f)){
BorderStyle = UITextBorderStyle.Bezel,
TextColor = UIColor.Black,
Placeholder = "<enter a URL>",
Text = "http://ios.xamarin.com/",
BackgroundColor = UIColor.White,
AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
ReturnKeyType = UIReturnKeyType.Go,
KeyboardType = UIKeyboardType.Url,
AutocapitalizationType = UITextAutocapitalizationType.None,
AutocorrectionType = UITextAutocorrectionType.No,
ClearButtonMode = UITextFieldViewMode.Always
};
urlField.ShouldReturn = delegate (UITextField field){
field.ResignFirstResponder ();
web.LoadRequest (NSUrlRequest.FromUrl (new NSUrl (field.Text)));
return true;
};
View.AddSubview (urlField);
web.LoadRequest (NSUrlRequest.FromUrl (new NSUrl ("http://ios.xamarin.com/")));
}
示例7: WeatherViewController
// We use MonoTouch.Dialog to visually represent the parsed json data
// http://docs.xamarin.com/guides/ios/user_interface/monotouch.dialog/
public WeatherViewController(RootObject json)
: base(null, true)
{
var item = json.Query.Results.Channel.Item;
Root = new RootElement ("Weather in Boston, MA") {
new Section (item.Title) {
new StyledStringElement ("Latitude", item.Lat, UITableViewCellStyle.Subtitle),
new StyledStringElement ("Longitude", item.Lon, UITableViewCellStyle.Subtitle),
new RootElement ("Current Condition") {
new Section () {
new StyledStringElement ("Code", item.Condition.Code, UITableViewCellStyle.Subtitle),
new StyledStringElement ("Date", item.Condition.Date, UITableViewCellStyle.Subtitle),
new StyledStringElement ("Temp", item.Condition.Temp, UITableViewCellStyle.Subtitle),
new StyledStringElement ("Text", item.Condition.Text, UITableViewCellStyle.Subtitle)
}
},
new RootElement ("Forecast") {
item.Forecast.Where (f => f != null).Select (f => {
return new Section (f.Day + ", " + f.Date) {
new StyledStringElement ("Code", f.Code, UITableViewCellStyle.Subtitle),
new StyledStringElement ("High", f.High, UITableViewCellStyle.Subtitle),
new StyledStringElement ("Low", f.Low, UITableViewCellStyle.Subtitle),
new StyledStringElement ("Text", f.Text, UITableViewCellStyle.Subtitle)
};
})
},
new HtmlElement ("Link to site", item.Link),
new StringElement ("Description", ()=> {
var webViewController = new UIViewController ();
var webView = new UIWebView (View.Frame);
webView.LoadHtmlString (item.Description, null);
webViewController.View.Add (webView);
NavigationController.PushViewController (webViewController, true);
}),
new RootElement ("Guid") {
new Section () {
new StyledStringElement ("IsPermaLink", item.Guid.IsPermaLink, UITableViewCellStyle.Subtitle),
new StyledStringElement ("Content", item.Guid.Content, UITableViewCellStyle.Subtitle)
}
}
},
new Section () {
new RootElement ("Show Parsed Json") {
new Section () {
new MultilineElement (json.Dump ())
}
}
}
};
}
示例8: ViewDidLoad
/// <summary>
/// Configures the UIWebView when the view loads.
/// </summary>
public override void ViewDidLoad()
{
base.ViewDidLoad();
Title = _category.Name;
View.BackgroundColor = UIColor.GroupTableViewBackgroundColor;
string html = ReplaceTokens();
_webView = new UIWebView();
_webView.Frame = new RectangleF(0, 0, 320, 480);
_webView.LoadHtmlString(html, new NSUrl("/"));
_webView.BackgroundColor = UIColor.Clear;
_webView.Opaque = false;
View.AddSubview(_webView);
}
示例9: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
Title = "Tips";
View.BackgroundColor = UIColor.GroupTableViewBackgroundColor;
ReadHelpHtml();
_webView = new UIWebView();
_webView.Frame = new RectangleF(0, 0, 320, 480);
_webView.LoadHtmlString(_tipsHtml, new NSUrl("/"));
_webView.BackgroundColor = UIColor.Clear;
_webView.Opaque = false;
View.AddSubview(_webView);
}
示例10: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
webView = new UIWebView(UIScreen.MainScreen.Bounds);
View.Add(webView);
// Intercept URL loading to handle native calls from browser
//webView.ShouldStartLoad += HandleShouldStartLoad;
// Render the view from the type generated from RazorView.cshtml
//var model = App.Database.GetItems().ToList();
var template = new MainPage(); //new RazorView() ;
var page = template.GenerateString();
webView.LoadHtmlString(page, NSBundle.MainBundle.BundleUrl);
}
示例11: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
webView = new UIWebView (UIScreen.MainScreen.Bounds);
View.Add (webView);
// Intercept URL loading to handle native calls from browser
webView.ShouldStartLoad += HandleShouldStartLoad;
// Render the view from the type generated from RazorView.cshtml
var model = App.Database.GetItems ().ToList ();
var template = new TodoList () { Model = model };
var page = template.GenerateString ();
webView.LoadHtmlString (page, NSBundle.MainBundle.BundleUrl);
}
示例12: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
webView = new UIWebView { ScalesPageToFit = true };
webView.LoadStarted += delegate {
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
};
webView.LoadFinished += delegate {
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
};
webView.LoadHtmlString(FormatText(), new NSUrl());
webView.SizeToFit();
webView.Frame = new RectangleF (0, 0, this.View.Frame.Width, this.View.Frame.Height - 44);
this.View.AddSubview(webView);
}
示例13: Selected
public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
{
tableView.DeselectRow (path, true);
//base.Selected (dvc, tableView, path);
var evc = new EmptyViewController(()=>
{
nav.PopViewControllerAnimated(true);
}, Caption);
var vc = new WebViewController (this) {
Autorotate = dvc.Autorotate
};
var web = new UIWebView (UIScreen.MainScreen.ApplicationFrame){
BackgroundColor = UIColor.White,
ScalesPageToFit = true,
AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
};
web.LoadStarted += delegate {
NetworkActivity = true;
var indicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White);
vc.NavigationItem.RightBarButtonItem = new UIBarButtonItem(indicator);
indicator.StartAnimating();
};
web.LoadFinished += delegate {
NetworkActivity = false;
vc.NavigationItem.RightBarButtonItem = null;
};
web.LoadError += (webview, args) => {
NetworkActivity = false;
vc.NavigationItem.RightBarButtonItem = null;
if (web != null)
web.LoadHtmlString (String.Format ("<html><center><font size=+5 color='red'>An error occurred:<br>{0}</font></center></html>", args.Error.LocalizedDescription), null);
};
vc.NavigationItem.Title = Caption;
vc.View.AddSubview (web);
//vc.View.Frame = new RectangleF(0, 41 , 320, 480 - 41);
evc.Add(vc.View);
nav.PushViewController(evc, true);
web.LoadRequest (NSUrlRequest.FromUrl (new NSUrl (Url)));
}
示例14: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
// no XIB !
webView = new UIWebView()
{
ScalesPageToFit = false
};
webView.LoadHtmlString(FormatText(), new NSUrl());
// Set the web view to fit the width of the app.
webView.SizeToFit();
// Reposition and resize the receiver
webView.Frame = new RectangleF (0, 0, this.View.Bounds.Width, this.View.Bounds.Height);
// Add the table view as a subview
this.View.AddSubview(webView);
}
示例15: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
_view = new UIView();
_view.BackgroundColor = UIColor.GroupTableViewBackgroundColor;
UILabel label = new UILabel();
label.Text = _stopInfo.StopName;
label.BackgroundColor = UIColor.GroupTableViewBackgroundColor;
label.SizeToFit();
label.Frame = new RectangleF(10,0, 300, 40);
_view.Add(label);
UIButton button = UIButton.FromType(UIButtonType.RoundedRect);
button.SetTitle("Legg til i favoritter", UIControlState.Normal);;
button.Frame = new RectangleF(10, 120, 150, 50);
_view.Add(button);
_view.SizeToFit();
button.TouchUpInside += delegate {
_busStopRepository.AddFavorite(_stopInfo);
};
webView = new UIWebView { ScalesPageToFit = false };
webView.LoadHtmlString (FormatText (), new NSUrl ());
// Set the web view to fit the width of the app.
webView.SizeToFit ();
// Reposition and resize the receiver
_view.Frame = new RectangleF (0, 0, this.View.Bounds.Width, this.View.Bounds.Height);
// Add the table view as a subview
this.View.AddSubview (_view);
}