Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何区分来自LoadHtmlString的请求和事件ShouldStartLoad中的网页请求?_Objective C_Xamarin.ios_Monodevelop - Fatal编程技术网

Objective c 如何区分来自LoadHtmlString的请求和事件ShouldStartLoad中的网页请求?

Objective c 如何区分来自LoadHtmlString的请求和事件ShouldStartLoad中的网页请求?,objective-c,xamarin.ios,monodevelop,Objective C,Xamarin.ios,Monodevelop,我在UIWebView中内置了离线功能,这样当iPhone进入航空公司模式时,已经加载的页面仍然可用。基本算法是: 1) 检测NavigationType LinkClicked,在这种情况下,从脱机缓存加载请求的页面 2) 当离线缓存完成加载请求的URL时,它会触发offlineRequestSuccess通知 3) my webview处理此通知并将响应字符串加载到webview中 以下是我的代码: public class UIMobileformsWebView : UIWebView

我在UIWebView中内置了离线功能,这样当iPhone进入航空公司模式时,已经加载的页面仍然可用。基本算法是:

1) 检测NavigationType LinkClicked,在这种情况下,从脱机缓存加载请求的页面

2) 当离线缓存完成加载请求的URL时,它会触发offlineRequestSuccess通知

3) my webview处理此通知并将响应字符串加载到webview中

以下是我的代码:

public class UIMobileformsWebView : UIWebView
{        
    private UIMobileformsWebView () : base()
    {
        UIWebView self = this;
        this.ShouldStartLoad = (webview, request, navigationType) => {                
            if (navigationType == UIWebViewNavigationType.LinkClicked) {
                OfflineRequest.GetInstance().FetchUrl(request.URL);
                return false;
            }
            return true;
        };
        NSNotificationCenter.DefaultCenter.AddObserver(new NSString("offlineRequestSuccess"), new Action<NSNotification>(OfflineRequestSuccess));
    }

    void OfflineRequestSuccess (NSNotification notification)
    {
        ASIHTTPRequest theRequest = (ASIHTTPRequest)notification.Object;
        String response = System.IO.File.ReadAllText(theRequest.DownloadDestinationPath);
        this.LoadHtmlString(response, theRequest.URL);
    }
}

在OfflineRequestSuccess中将来自我的网页的请求与来自LoadHtmlString的请求区分开来。有人知道我怎样才能做出这种区分吗

如果在使用LoadHtmlString时将委托的布尔属性设置为true,并在完成时将其重置,则可以轻松区分这些属性。web视图不知道该属性,并且不会将其设置为true。如果属性为“是”,则必须是因为LoadHtmlString请求

if (navigationType == UIWebViewNavigationType.LinkClicked) {