Remove splash screen for iOS

邮差的信 提交于 2019-12-11 20:44:18

问题


I want to remove splash screen in iOS app.

I searched in internet and found many ways which work for others, but this ways don't work for me.

1- with ngCordova :

I downloaded ngCordova and add ng-cordova.js to my app before cordova.js and then in app.js I use ngCordova :

angular.module('MyApp', ['ionic', 'starter.controllers', 'ngCordova'])

    .run(function ($ionicPlatform, $cordovaSplashscreen) {

        $cordovaSplashscreen.hide();
    });

with this code I get this error:

0     533012   error    TypeError: undefined is not an object (evaluating 'navigator.splashscreen.hide'), http://192.168.1.28:8100/lib/ngCordova/dist/ng-cordova.min.js, Line: 2

2- with navigator.splashscreen : According to many solutions I use navigator.splashscreen.hide() but in this way I get this error:

0     693078   error    TypeError: undefined is not an object (evaluating 'navigator.splashscreen.hide'), http://192.168.1.28:8100/js/app.js, Line: 13

3- with cordova.exec: at least I use cordova.exec :

cordova.exec(null, null, "SplashScreen", "hide", []);

But I get this error message :

0     803835   error    TypeError: undefined is not a function (evaluating 'cordova.exec(null, null, "SplashScreen", "hide", [])'), http://192.168.1.28:8100/js/app.js, Line: 12

I using ionic with cordova 4.1.2 on MacBook Pro .

What should I do for removing splassh screen ?


回答1:


I had the same problem, after a lot of messing around I found I did a number of things wrong:

These tips apply for a few issues I've had with plugins:

1) make sure 'lib/ngCordova/dist/ng-cordova.min.js' is after 'lib/ionic/js/ionic.bundle.js'

2) make sure you haven't removed 'cordova.js' and that it comes after the prior ones. (I did for browser development but you need it for the emulator and mobile device).

3) make sure you are inside the ready block:

$ionicPlatform.ready(function() {
    $cordovaSplashscreen.hide();
});

4) sometimes (especially the facebook plugin) you need to remove the platform and re add it (takes 5 seconds).

if a plugin gives you errors (like the facebook one): a) remove the plugin first b) then remove the platform c) then add the platform d) then add the plugin.



来源:https://stackoverflow.com/questions/27079697/remove-splash-screen-for-ios

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