ios UIWebView 区分加载和点击连接

UIWebView的Delegate方法中有

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;


其中navigationType可以判断出来该事件是UIWebView的loadRequest 还是touch URL连接


typedef enum {

    UIWebViewNavigationTypeLinkClicked,

    UIWebViewNavigationTypeFormSubmitted,

    UIWebViewNavigationTypeBackForward,

    UIWebViewNavigationTypeReload,

    UIWebViewNavigationTypeFormResubmitted,

    UIWebViewNavigationTypeOther

} UIWebViewNavigationType;


在UIWebView加载的时候navigationType == UIWebViewNavigationTypeOther

在UIWebView加载完成后,用户点击一个连接时navigationType == UIWebViewNavigationTypeLinkClicked。


这样就可以区分UIWebView是加载(在UIWebView中显示网页)还是连接(在Safari中显示网页)

你可能感兴趣的:(ios)