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

放肆的年华 提交于 2019-12-04 14:49:24

问题


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 retail environment.

Under iOS 7 all worked fine, but since updating to iOS 8 an alert "Guided Access is enabled. Triple-click the home button to exit" is displayed at the top of the screen almost every time a link on the web page is tapped.

I've tried creating a new app from scratch that has nothing other than a UIWebView element in it, and the problem still occurs. I've filed a bug with Apple, but am urgently seeking a way to workaround this problem so that the alert is no longer displayed to customers.


回答1:


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.




回答2:


I finally found a workaround: migrate from UIWebView to WKWebView !!! Works for me !



来源:https://stackoverflow.com/questions/26744534/alert-displayed-when-tapping-links-in-uiwebview-with-guided-access-enabled-under

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!