在iOS 8中启用Guided Access的UIWebView中点击链接时显示警报 [英] Alert displayed when tapping links in UIWebView with Guided Access enabled under iOS 8

查看:89
本文介绍了在iOS 8中启用Guided Access的UIWebView中点击链接时显示警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个相当基本的iOS应用程序,它通过UIWebView元素使用Web内容。该应用程序需要在面向客户的零售环境中运行时以引导访问模式运行。

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.

在iOS 7下,所有工作正常,但自从更新到iOS 8后几乎每次点击网页上的链接时,屏幕顶部都会显示引导访问已启用。三次单击主页按钮退出。

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.

我尝试从头开始创建一个新的应用程序,其中只有一个UIWebView元素,问题仍然存在。我已向Apple提交了一个错误,但我正在寻求解决此问题的方法,以便不再向客户显示警报。

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.

推荐答案

感谢来自Kiosk Pro App的Chris,我找到了一个解决方法。

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

你需要转换所有请求(仅当启动了Guided Access时)和导航输入UIWebViewNavigationTypeLinkeded到导航类型UIWebViewNavigationTypeOther

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.

以下是来自自适应频道的Blandine的实现:

Here is an implementation by Blandine from Adaptive Channel :

在方法中:

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

添加:

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

希望有所帮助。

这篇关于在iOS 8中启用Guided Access的UIWebView中点击链接时显示警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆