本文整理汇总了C#中UIWebView类的典型用法代码示例。如果您正苦于以下问题:C# UIWebView类的具体用法?C# UIWebView怎么用?C# UIWebView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UIWebView类属于命名空间,在下文中一共展示了UIWebView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
webView = new UIWebView (new RectangleF(0, (_addCancelButton) ? navigationBarHeight : 0, View.Frame.Width, (_addCancelButton) ? View.Frame.Height - navigationBarHeight : View.Frame.Height));
webView.Delegate = new WebViewDelegate(RequestStarted, RequestFinished);
if (!_addCancelButton) {
this.View.AddSubview (webView);
} else {
var cancelButton = new UIBarButtonItem (UIBarButtonSystemItem.Cancel);
cancelButton.Clicked += (object sender, EventArgs e) => {
_cancelled();
this.DismissViewController(true, null);
};
var navigationItem = new UINavigationItem {
LeftBarButtonItem = cancelButton
};
navigationBar = new UINavigationBar (new RectangleF (0, 0, View.Frame.Width, navigationBarHeight));
navigationBar.PushNavigationItem (navigationItem, false);
this.View.AddSubviews (navigationBar, webView);
}
}
示例2: FinishedLaunching
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
App_Window = new UIWindow(UIScreen.MainScreen.Bounds);
var vc = new UIViewController();
var view = new UIView();
var button = UIButton.FromType(UIButtonType.RoundedRect);
button.Frame = new RectangleF(0, 0, 100, 40);
button.SetTitle("Do It", UIControlState.Normal);
button.TouchDown += delegate {
Test_JSON();
};
view.AddSubview(button);
Browser = new UIWebView();
Browser.Frame = new RectangleF(0, 50, UIScreen.MainScreen.Bounds.Width,
UIScreen.MainScreen.Bounds.Height-50);
view.AddSubview(Browser);
vc.View = view;
App_Window.RootViewController = vc;
App_Window.MakeKeyAndVisible();
return true;
}
示例3: ShouldStartLoad
public override bool ShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
{
bool shouldStart = true;
string url = request.Url.ToString();
if (url.Contains("js-frame"))
{
shouldStart = false;
string pendingArgs = bridge.webBrowser.EvaluateJavascript("window.locationMessenger.pendingArg.toString();");
// Using JsonConvert.Deserialze<string[]> blows up under MonoTouch, so manually build the array of args instead
JArray argsJArray = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(pendingArgs);
string[] args = new string[argsJArray.Count];
for (int i = 0; i < argsJArray.Count; i++)
args[i] = (string)argsJArray[i];
if (args[0] == "HandleScriptPropertyChanged")
{
if (args.Length == 3)
bridge.HandleScriptPropertyChanged(args[1], args[2], null);
else
bridge.HandleScriptPropertyChanged(args[1], args[2], args[3]);
}
else if (args[0] == "InvokeViewModelIndexMethod")
bridge.InvokeViewModelMethod(args[1], args[2], args[3]);
else if (args[0] == "InvokeViewModelMethod")
bridge.InvokeViewModelMethod(args[1], args[2]);
else if (args[0] == "HandleDocumentReady")
bridge.HandleDocumentReady();
else if (args[0] == "HostLog")
bridge.HostLog(args[1]);
else
SpinnakerConfiguration.CurrentConfig.Log(SpinnakerLogLevel.Error,"Ignoring unrecognized call from javascript for [" + args[0] + "] - this means that javascript in the view is trying to reach the host but with bad arguments");
}
return shouldStart;
}
示例4: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
if (!string.IsNullOrEmpty(IdentityProviderName))
Title = IdentityProviderName;
_webView = new UIWebView(new RectangleF(0,0, View.Bounds.Width, View.Bounds.Height))
{
AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleBottomMargin
};
_webView.ShouldStartLoad += ShouldStartLoad;
_webView.LoadStarted +=
(sender, args) => UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
_webView.LoadFinished +=
(sender, args) => UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
_webView.LoadError += (sender, args) =>
{
//Some providers have this strange Frame Interrupted Error :-/
if (args.Error.Code == 102 && args.Error.Domain == "WebKitErrorDomain") return;
_messageHub.Publish(new RequestTokenMessage(this) { TokenResponse = null });
};
View.AddSubview(_webView);
_webView.LoadRequest(new NSUrlRequest(Url));
}
示例5: HandleShouldStartLoad
bool HandleShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
{
// If the URL is not our own custom scheme, just let the webView load the URL as usual
const string scheme = "hybrid:";
if (request.Url.Scheme != scheme.Replace (":", ""))
return true;
// This handler will treat everything between the protocol and "?"
// as the method name. The querystring has all of the parameters.
var resources = request.Url.ResourceSpecifier.Split ('?');
var method = resources [0];
var parameters = System.Web.HttpUtility.ParseQueryString (resources [1]);
if (method == "UpdateLabel") {
var textbox = parameters ["textbox"];
// Add some text to our string here so that we know something
// happened on the native part of the round trip.
var prepended = string.Format ("C# says: {0}", textbox);
// Build some javascript using the C#-modified result
var js = string.Format ("SetLabelText('{0}');", prepended);
webView.EvaluateJavascript (js);
}
return false;
}
示例6: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
navBar = new UIToolbar();
navBar.Frame = new CGRect (0, View.Frame.Height-40, View.Frame.Width, 40);
navBar.TintColor = UIColor.Gray;
items = new [] {
new UIBarButtonItem (UIBarButtonSystemItem.Stop, (o, e) => {
webView.StopLoading ();
DismissViewController (true, null);
}),
new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace, null),
new UIBarButtonItem (UIBarButtonSystemItem.Refresh, (o, e) => webView.Reload ())
};
navBar.Items = items;
webView = new UIWebView ();
webView.Frame = new CGRect (0, 0, View.Frame.Width, View.Frame.Height-40);
webView.ScalesPageToFit = true;
webView.SizeToFit ();
webView.LoadRequest (url);
navBar.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin;
webView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
View.AddSubviews (new UIView[] { webView, navBar });
}
示例7: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
txt = new UITextView (new CoreGraphics.CGRect (100, 50, 200, 30));
txt.BackgroundColor = UIColor.Gray;
txt.TextColor = UIColor.White;
txt.Text="https://auth.alipay.com/login/index.htm";
UIButton btn = new UIButton (UIButtonType.System);
btn.Frame = new CoreGraphics.CGRect (330, 50, 100, 30);
btn.SetTitle ("GO", UIControlState.Normal);
btn.TouchUpInside += Btn_TouchUpInside;
UIButton btnHtmlString = new UIButton (UIButtonType.System);
btnHtmlString.Frame = new CoreGraphics.CGRect (450, 50, 100, 30);
btnHtmlString.SetTitle ("Html String", UIControlState.Normal);
btnHtmlString.TouchUpInside += BtnHtmlString_TouchUpInside;
UIButton btnFile = new UIButton (UIButtonType.System);
btnFile.Frame = new CoreGraphics.CGRect (580, 50, 100, 30);
btnFile.SetTitle ("Load File", UIControlState.Normal);
btnFile.TouchUpInside += BtnFile_TouchUpInside;
// Perform any additional setup after loading the view, typically from a nib.
webView=new UIWebView(new CoreGraphics.CGRect(100,100,600,700));
webView.ContentMode = UIViewContentMode.Center;
this.View.AddSubviews (txt, btn, webView, btnHtmlString, btnFile);
}
示例8: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
navBar = new UIToolbar ();
navBar.Frame = new RectangleF (0, this.View.Frame.Height-130, this.View.Frame.Width, 40);
items = new UIBarButtonItem [] {
new UIBarButtonItem ("Back", UIBarButtonItemStyle.Bordered, (o, e) => { webView.GoBack (); }),
new UIBarButtonItem ("Forward", UIBarButtonItemStyle.Bordered, (o, e) => { webView.GoForward (); }),
new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace, null),
new UIBarButtonItem (UIBarButtonSystemItem.Refresh, (o, e) => { webView.Reload (); }),
new UIBarButtonItem (UIBarButtonSystemItem.Stop, (o, e) => { webView.StopLoading (); })
};
navBar.Items = items;
SetNavBarColor();
webView = new UIWebView ();
webView.Frame = new RectangleF (0, 0, this.View.Frame.Width, this.View.Frame.Height-130);
webView.LoadStarted += delegate {
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
};
webView.LoadFinished += delegate {
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
};
webView.ScalesPageToFit = true;
webView.SizeToFit ();
webView.LoadRequest (url);
this.View.AddSubview (webView);
this.View.AddSubview (navBar);
}
示例9: 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
}
示例10: LoadView
public override void LoadView()
{
base.LoadView ();
bool isV7 = UIDevice.CurrentDevice.CheckSystemVersion (7, 0);
View.BackgroundColor = UIColor.White;
niceSegmentedCtrl = new SDSegmentedControl (new string [] { "Google", "Bing", "Yahoo" });
if (isV7)
niceSegmentedCtrl.Frame = new RectangleF (0, 10, 320, 44);
else
niceSegmentedCtrl.Frame = new RectangleF (0, 0, 320, 44);
niceSegmentedCtrl.SetImage (UIImage.FromBundle ("google"), 0);
niceSegmentedCtrl.SetImage (UIImage.FromBundle ("bicon"), 1);
niceSegmentedCtrl.SetImage (UIImage.FromBundle ("yahoo"), 2);
niceSegmentedCtrl.ValueChanged += HandleValueChanged;
if (isV7)
browser = new UIWebView (new RectangleF (0, 55, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height - 64));
else
browser = new UIWebView (new RectangleF (0, 45, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height - 64));
browser.LoadRequest (new NSUrlRequest ( new NSUrl ("http://google.com")));
browser.AutosizesSubviews = true;
View.AddSubviews ( new UIView[] { niceSegmentedCtrl, browser });
}
示例11: HandleShouldStartLoad
bool HandleShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
{
// If the URL is not our own custom scheme, just let the webView load the URL as usual
var scheme = "app:";
if (request.Url.Scheme != scheme.Replace(":", ""))
return true;
var resources = request.Url.ResourceSpecifier.Split('?');
var method = resources[0];
if (method == "QR")
{
var scanner = new ZXing.Mobile.MobileBarcodeScanner();
scanner.Scan().ContinueWith(result => {
if (result != null){
var code = result.Result.Text;
this.InvokeOnMainThread(new NSAction(() => webView.LoadRequest(new NSUrlRequest(new NSUrl(MainUrl + "code?value=" + code)))));
}
});
}
return false;
}
示例12: 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)));
}
示例13: FinishedLaunching
public override bool FinishedLaunching (UIApplication application, NSDictionary options)
{
// Register our custom url protocol
NSUrlProtocol.RegisterClass (new ObjCRuntime.Class (typeof (ImageProtocol)));
controller = new UIViewController ();
web = new UIWebView () {
BackgroundColor = UIColor.White,
ScalesPageToFit = true,
AutoresizingMask = UIViewAutoresizing.All
};
if (UIDevice.CurrentDevice.CheckSystemVersion (7, 0))
web.Frame = new CGRect (0, 20,
UIScreen.MainScreen.Bounds.Width,
UIScreen.MainScreen.Bounds.Height - 20);
else
web.Frame = UIScreen.MainScreen.Bounds;
controller.NavigationItem.Title = "Test case";
controller.View.AutosizesSubviews = true;
controller.View.AddSubview (web);
web.LoadRequest (NSUrlRequest.FromUrl (NSUrl.FromFilename (NSBundle.MainBundle.PathForResource ("test", "html"))));
window = new UIWindow (UIScreen.MainScreen.Bounds);
window.BackgroundColor = UIColor.White;
window.MakeKeyAndVisible ();
window.RootViewController = controller;
return true;
}
示例14: Create
public static BaseItemView Create (CGRect frame, NodeViewController nodeViewController, TreeNode node, string filePath, UIColor kleur)
{
var view = BaseItemView.Create(frame, nodeViewController, node, kleur);
UIWebView webView = new UIWebView();
string extension = Path.GetExtension (filePath);
if (extension == ".odt") {
string viewerPath = NSBundle.MainBundle.PathForResource ("over/viewer/index", "html");
Uri fromUri = new Uri(viewerPath);
Uri toUri = new Uri(filePath);
Uri relativeUri = fromUri.MakeRelativeUri(toUri);
String relativePath = Uri.UnescapeDataString(relativeUri.ToString());
NSUrl finalUrl = new NSUrl ("#" + relativePath.Replace(" ", "%20"), new NSUrl(viewerPath, false));
webView.LoadRequest(new NSUrlRequest(finalUrl));
webView.ScalesPageToFit = true;
view.ContentView = webView;
return view;
} else {
NSUrl finalUrl = new NSUrl (filePath, false);
webView.LoadRequest(new NSUrlRequest(finalUrl));
webView.ScalesPageToFit = true;
view.ContentView = webView;
return view;
}
}
示例15: RowSelected
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{
var webViewController = new UIViewController ();
var button = new UIBarButtonItem ("Back", UIBarButtonItemStyle.Plain, null);
var custom = new UIButton (new RectangleF (0, 0, 26, 15));
custom.SetBackgroundImage(UIImage.FromFile("./Assets/back.png"), UIControlState.Normal);
custom.TouchUpInside += (sender, e) => webViewController.NavigationController.PopViewControllerAnimated (true);
button.CustomView = custom;
webViewController.NavigationItem.LeftBarButtonItem = button;
var spinner = new UIActivityIndicatorView (UIActivityIndicatorViewStyle.WhiteLarge);
spinner.Center = new PointF (160, 160);
spinner.HidesWhenStopped = true;
var webView = new UIWebView (tableView.Bounds);
webView.Opaque = false;
webView.BackgroundColor = UIColor.Black;
webView.AddSubview (spinner);
spinner.StartAnimating ();
webView.LoadRequest (new NSUrlRequest (new NSUrl (string.Format(RequestConfig.Video, items[indexPath.Row].Id))));
webViewController.View = webView;
webViewController.Title = items[indexPath.Row].Category;
webView.LoadFinished += (object sender, EventArgs e) => {
spinner.StopAnimating();
};
((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).
Video.InternalTopNavigation.PushViewController (webViewController,true);
tableView.DeselectRow (indexPath, true);
}