Alert displayed when tapping links in UIWebView with Guided Access enabled under iOS 8

后端 未结 2 1962
日久生厌
日久生厌 2021-02-11 08:35

I have written a fairly basic iOS app that makes use of web content via a UIWebView element. The app needs to run in Guided Access mode as it is running in a customer-facing re

2条回答
  •  我在风中等你
    2021-02-11 08:53

    I've found a workaround thanks to Chris from Kiosk Pro App.

    You need to transform all requests (only when Guided Access is on) with navigation type "UIWebViewNavigationTypeLinkClicked" to navigation type "UIWebViewNavigationTypeOther"

    One issue with this workaround is that the Guided Access message still appears for links using types "Form Submitted" and "Form Resubmitted". Trying to transform these types could potentially cause an error with loading the page.

    Here is an implementation by Blandine from Adaptive Channel :

    In the method :

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

    Just add :

    if (UIAccessibilityIsGuidedAccessEnabled()) {
            if (navigationType == UIWebViewNavigationTypeLinkClicked ) {
                navigationType = UIWebViewNavigationTypeOther;
                [webView loadRequest:request];
                return NO;
            }
    }
    

    Hope it helps.

提交回复
热议问题