Phonegap Build inAppBrowser事件不会在iOS 6& 7 [英] Phonegap Build inAppBrowser event does not fire after view change in iOS 6 & 7

查看:176
本文介绍了Phonegap Build inAppBrowser事件不会在iOS 6& 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PhoneGap Build版本3.3.0构建一个跨平台应用程序。该应用是一个新闻应用,因此需要更新DOM,因为加载了不同的视图。每次发生这种情况,旧页面将被删除并被新的视图渲染所取代。该应用程序是围绕backbone.js构建的,使用jQuery和Twig来呈现视图。

I am building a cross platform app using PhoneGap Build, version 3.3.0. The app is a news app, so requires updating of the DOM as different views are loaded. Every time this happens the old page is removed and replaced by the new view render. The app is built around backbone.js , using jQuery and Twig to render the views.

我使用inAppBrowser处理外部网站的链接,并已成功设置这些链接:

I am using the inAppBrowser to handle links to external sites, and have successfully set these up, using:

<gap:plugin name="org.apache.cordova.inappbrowser" />

,以及指向

<script src="phonegap.js"></script>

。然后我使用

window.open('myURL', '_blank', 'location=yes');

这在我第一次在会话中使用时工作正常。即使浏览器关闭,并且选择了同一视图上的另一个链接,浏览器仍然可以正常工作。

and this works fine the first time I use it in a session. Even if the browser is then closed and another link on the same view is selected, the browser still works.

但是,在iOS 6+中,通过另一个视图,则新视图中的链接不会触发。 onclick事件附加到链接肯定是启动(我可以通过使用警报),但inAppBroswer不打开。但是,如果我退出应用程序,然后返回到它,inAppBroswer已打开。这就像失去了应用程序的焦点触发排队的事件。

However, in iOS 6+, if the view is then replaced by another view, then the links in the new view do not fire. The onclick event attached to the link is definitely firing (I can tell by using alerts), but the inAppBroswer does not open. However, if I exit the app and then return to it, the inAppBroswer has opened. It is as if losing the focus on the app fires off the queued event.

我已经确认这种行为通过在loadstart事件处理程序中放置一个警报,这不会

I have confirmed this behaviour by placing an alert in the loadstart event handler, this does not fire until exiting the app and returning to it.

我尝试保持对inAppBrowser的持久引用,并在实例关闭之后销毁它。我也尝试在创建inAppBroswer实例后调用 .show()方法,但是这一切似乎没有任何区别。

I have tried keeping a persistent reference to the the inAppBrowser and destroying the instance after it has has closed. I have also tried calling the .show() method after creating the inAppBroswer instance, but none of this seems to make any difference.

这是其他人遇到的问题吗?我找不到关于这个具体问题的另一个问题。

Is this an issue that anyone else has come across? I could not find another question about this specific issue. This only seems to happen in iOS 6 and 7, not in Android.

感谢

推荐答案

似乎已经解决了这个问题,本文着眼于同一个问题(在不同的上下文中):

Seem to have solved it, this article looks at the same issue (in a different context):

https://issues.apache.org/jira/browse/CB-2102

一个解决方案是使用iframe桥模式。说明在这里:

One solution that came out of this was to use iframe bridge mode. Instructions are here:

https://groups.google.com/forum/#!msg/phonegap/iNl2M57xPEA/t2BW2kBXsbYJ

我可以通过致电以下:

var exec = cordova.require('cordova/exec');
exec.setJsToNativeBridgeMode(exec.jsToNativeModes.IFRAME_NAV);

,现在解决了我的应用程序的问题。

on the deviceready event, and this now solves the problem for my app.

希望这可以帮助有相同问题的任何人。

Hope this helps anyone with the same issue.

这篇关于Phonegap Build inAppBrowser事件不会在iOS 6&amp; 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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