iOS:无法在AppBrowser中启动cordova -> "Warning: Attempt to present <inAppBrowser> on <MainViewController> while a presentation is in progress"

标签 ios xcode cordova inappbrowser

我真的需要一些帮助,因为我对 iOS 和 Phonegap 开发非常陌生,而且我能找到的 Xcode 警告上的所有主题都是关于 Objective-C 的。

由于我的应用程序主要是用 Cordova (Phonegap) 编写的,这些解决方案并没有多大帮助。

那么,有什么可说的:

我有一个简单的启动屏幕,您可以在其中启动条形码扫描仪。结果(最终总是一个 url)应该显示在 cordova 的 inAppBrowser 中。

如果我用“_self”调用window.open(),它可以工作,但据我发现,很难返回到开始屏幕。 所以我想用 inAppBrowser 调用 url,这样就有一个“完成”按钮,但 Xcode 尖叫:

"Warning: Attempt to present <CDVInAppBrowserViewController: 0x1ed97060> on <MainViewController: 0x1ed64730> while a presentation is in progress!"

这是我调用 window.open() 函数的 JavaScript 代码...

app.initialize();

function demoScan() {
  try {
    var scanned = scan();
  } catch (e) {
    alert('scan failed');
  }
}

function scan() {
   var scanner = window.cordova.require("cordova/plugin/BarcodeScanner");
   scanner.scan(  function (result) {
      var ref = window.open(encodeURI(result.text),'_blank','location=yes');
        },
        function (error) {
          ("Scanning failed: " + error);
      });
   }

最后,我只需要一个(简单的)解决方案,当我在条形码扫描仪正在调用的网页上时返回到起始页“index.html”。如果是通过 inAppBrowser 或在 WebView 中使用自编码的“后退”按钮,我真的不在乎。

提前致谢! :)

最佳答案

好的,我找到答案了。您必须在调用 inAppBrowser 之前设置超时:

setTimeout( function() { 
               var ref = window.open(encodeURI(result.text),'_blank','location=no');
            }, 500);

显然,iOS 需要一些时间来结束它正在做的事情,然后才能启动 inAppBrowser。 在 Android 中,它可以正常工作,没有超时。

关于iOS:无法在AppBrowser中启动cordova -> "Warning: Attempt to present <inAppBrowser> on <MainViewController> while a presentation is in progress",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18209806/

相关文章:

java - New PhoneGap 3.0 无法解析import org.apache.cordova

android - 如何从 Card.io Phonegap iOS 和 Android 中删除/隐藏 Paypal Logo ?

jquery - Html5 音频无法在 Cordova App 中播放

android - Phonegap-2.10 : Hardware back button not working properly

android - 编译phonegap应用问题

iphone - InAppSettingsKit 中未显示子菜单

ios - SpriteKit - SKScene 边界不等于 SKView 边界

ios - 如何使用 iCloud 同步 iOS 和 OS X 应用程序?

ios - 使用 UIWebView (iOS) 无法自动登录 Google+?

swift - 将 Firebase 导入 Xcode 项目时出现问题