ionic无法加载网页但出现错误:操作无法完成。 (NSURLErrorDomain错误-999。)

时间:2015-07-06 14:27:29

标签: ios iphone angularjs ionic-framework ionic

虽然我正在使用AngularJS的离子应用程序并尝试在真实设备上使用它,但我得到以下输出:

    2015-07-06 17:00:15.760 MyApp[2195:832165] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///private/var/mobile/Containers/Data/Application/D7596A9C-B658-454C-8418-9A61B26091C2/Library/Cookies/Cookies.binarycookies
    2015-07-06 17:00:15.803 MyApp[2195:832165] Apache Cordova native platform version 3.8.0 is starting.
    2015-07-06 17:00:15.804 MyApp[2195:832165] Multi-tasking -> Device: YES, App: YES
    2015-07-06 17:00:15.811 MyApp[2195:832165] Unlimited access to network resources
    2015-07-06 17:00:16.460 MyApp[2195:832165] Resetting plugins due to page load.
    2015-07-06 17:00:16.911 MyApp[2195:832165] Finished load of: file:///private/var/mobile/Containers/Bundle/Application/47769242-72D0-4907-810A-85332D9564AF/MyApp.app/www/index.html#/home
    2015-07-06 17:00:24.247 MyApp[2195:832165] Resetting plugins due to page load.
    2015-07-06 17:00:24.259 MyApp[2195:832165] Failed to load webpage with error: The operation couldn’t be completed. (NSURLErrorDomain error -999.)
    2015-07-06 17:04:08.907 MyApp[2195:832165] Resetting plugins due to page load.
    2015-07-06 17:04:08.910 MyApp[2195:832165] Failed to load webpage with error: The operation couldn’t be completed. (NSURLErrorDomain error -999.)
    2015-07-06 17:06:19.397 MyApp[2195:832165] Received memory warning. // Here the the app crashes

index.html看起来像:

  <body ng-app="myapp.module">
    <ion-pane ng-controller="HomeCtrl" ng-init="check()">
      <ion-header-bar class="bar-stable">
        <h1 class="title">My ionic app</h1>
      </ion-header-bar>
      <ion-content class="home-content">
        <div class="welcome-message"> Welcome, <span ng-if="!userInfo.isAuthenticated">{{guest}}</span> <span ng-if="userInfo.isAuthenticated">{{userInfo.profile.name}}</span> !</div>

        <button type="button" class="button center-block button-positive" ng-show="userInfo.isAuthenticated" ng-click="logout()" name="button">{{logOutTextButton}}</button>
        <button type="button" class="button center-block button-positive" ng-hide="userInfo.isAuthenticated" ng-click="login()" name="button">{{loginTextButton}}</button>

      </ion-content>
      <footer>Footer text</footer>
    </ion-pane>

  </body>

2 个答案:

答案 0 :(得分:2)

从错误代码&#34; 999&#34;,看起来您在UIWebView加载第一个网址之前加载或重新加载第二个网址...

因此,系统取消了第一个并尝试加载您传递给它的第二个URL ...

答案 1 :(得分:1)

我的Cordova应用程序遇到了同样的错误,花了很多小时才找到根本原因。

第一件事,我观察到至少触发了“ onDeviceReady”事件(通过在其中放置警报语句)。因此,我怀疑它可能是“ onDeviceReady”内部可能引发错误的任何插件。我将对插件的所有调用放在单独的try-catch块中。这使得“ onDeviceReady”能够成功完成并启动应用程序。最后,我还发现了指向一个插件的错误日志。

希望这对以后的人有帮助。