我目前有一个带有密码登录表单的简单网站:
<input type="text" id="passwd" name="passwd" />
我希望能够在我的 iOS 应用程序中输入 PIN 码,并让它在我的 Web View 中提交密码表单。
我目前正在使用此加载我的 View :
myWebView.LoadRequest (new NSUrlRequest (new NSUrl("mysite.com")));
我发现有人可以使用 obj-c 执行此操作,但我不确定如何使用 C# 和 Xamarin 实现此操作。请帮忙。
谢谢!
最佳答案
这应该可以解决问题:
string password = "1234";
var req = new NSMutableUrlRequest (new NSUrl ("http://example.com"));
req.HttpMethod = "POST";
req.Body = NSData.FromString(String.Format("passwd={0}", password));
//req["Content-Length"] = req.Body.Length.ToString();
//req["Content-Type"] = "application/x-www-form-urlencoded charset=utf-8";
myWebView.LoadRequest (req);
关于c# - 如何使用 Xamarin 将表单字段从 iOS 提交到 UIWebView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26062729/