繁体   English   中英

ASP.Net LinkBut​​ton和iOS UIWebView

[英]ASP.Net LinkButton and iOS UIWebView

我发现,如果按钮是asp.net LinkButton ,则嵌入式UIWebView不会导致回发,但是它们可以与Button一起正常工作。 Safari会正常执行LinkButton的回发。

有什么解决方法吗?

程式码片段:

vwWebView.LoadRequest (new NSUrlRequest (new NSUrl (url)));

(我们正在使用monotouch,但这似乎是iOS问题)

事实证明,UIWebView的默认用户代理使IIS不将javascript发送到内容项。 解决方案是将Webview的用户代理手动设置为移动Safari的用户代理。

这是实现它的代码:

static public void SetUserAgent(UIWebView webview) {
    var agent = "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25";
    var webDocumentView = new NSObject(Messaging.IntPtr_objc_msgSend(webview.Handle,
                                                                     (new Selector("_documentView").Handle)));
    var webView = webDocumentView.GetNativeField("_webView");
    Messaging.void_objc_msgSend_IntPtr(webView.Handle, 
                                       (new Selector("setCustomUserAgent:")).Handle,                        
                                       (new NSString(agent)).Handle);
}

这篇文章提供了解决方案: http : //blog.reinforce-lab.com/2010/06/monotouchuiwebviewhowtochangeuseragent.html

以下帖子无效。 它只会对第一个请求进行分类,而不对顺序浏览进行分类: http ://monotouch.2284126.n4.nabble.com/seting-UIWebview-user-agent-objectiveC-question-td3807602.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM