ios 应用程序图标不会使用cordova 更改为自定义图标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17999766/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
App icon not changing to custom icon using cordova
提问by Stephen Cowley
I am trying to launch a cordova application using phonegap and cannot change the default app icon for iOS - (the actual icons not the splash screen). The default icons are always being copied into the Resouces --> icons folder and not my custom icons. I have used the specified methods from phonegap which suggest adding an icon tag into the config.xml file but this does not work? Restarting xcode and rebooting my app, and deleting it from the simulator/device dont work.
我正在尝试使用 phonegap 启动 Cordova 应用程序,但无法更改 iOS 的默认应用程序图标 - (实际图标不是启动画面)。默认图标总是被复制到资源 --> 图标文件夹中,而不是我的自定义图标。我使用了 phonegap 中指定的方法,建议在 config.xml 文件中添加一个图标标签,但这不起作用?重新启动 xcode 并重新启动我的应用程序,并将其从模拟器/设备中删除不起作用。
This is my config.xml file where i am specifing the icons...
这是我的 config.xml 文件,我在其中指定了图标...
...
<icon src="icon.png" />
<icon src="icon/ios/icon.png" gap:platform="ios" width="57" height="57" />
<icon src="icon/ios/[email protected]" gap:platform="ios" width="114" height="114" />
<icon src="icon/ios/icon-72.png" gap:platform="ios" width="72" height="72"/>
<!-- retina iPad support: PhoneGap 2.5.0+ only -->
<icon src="icon/ios/[email protected]" gap:platform="ios" width="144" height="144"/>
...
Any help would be amazing!
任何帮助都会很棒!
p.s. i have obviously checked all related posts i could find on this and no luck
ps我显然已经检查了我能找到的所有相关帖子,但没有运气
回答by VicM
I have faced the same problem, and despite searching for a definitive I had no luck trying to add the icon tags in the config.xml, neither by storing my icons on the www/icon folder so cordova build could copy them as probably expected. The documentation is not clear at all, scattered around different posts and solutions.
我遇到了同样的问题,尽管搜索了一个确定的我没有运气尝试在 config.xml 中添加图标标签,也没有通过将我的图标存储在 www/icon 文件夹中以便cordova build 可以按预期复制它们。文档根本不清楚,分散在不同的帖子和解决方案中。
So what works for me is the following, although I think is not the most elegant solution but it works.
所以对我有用的是以下内容,虽然我认为这不是最优雅的解决方案,但它有效。
Open your XCode project and store your icons on the folder Resources/icons or alternatively select your target project, go to Summary and scroll down until seeing the icons, click on any of them and right click on it and select open in finder so you have the correct location to override the default ones.
打开您的 XCode 项目并将您的图标存储在文件夹 Resources/icons 或选择您的目标项目,转到摘要并向下滚动直到看到图标,单击其中任何一个并右键单击它并选择在 finder 中打开,以便您覆盖默认位置的正确位置。
Be sure to use the same names that are used in the target folder to avoid confusion and CLEANyour project and BUILDit again.
确保使用与目标文件夹中使用的名称相同的名称以避免混淆并清理您的项目并重新构建它。
It is likely that if you Run the project in the simulator or device the default icon appear, in that case just uninstall your app from the device and build it again.
如果您在模拟器或设备中运行项目,很可能会出现默认图标,在这种情况下,只需从设备上卸载您的应用程序并重新构建它。
Hope it helps, however I would expect to have instead a method to modify the development www and let cordova buildcopy the icons and splashcreen.
希望它有所帮助,但是我希望有一种方法来修改开发 www 并让cordova构建复制图标和启动画面。
回答by Oliver
This method works but you need the full path including www.
<icon src="www/img/logo.png" />
此方法有效,但您需要包含 www 的完整路径。
<icon src="www/img/logo.png" />
This method was how i thought it should work but it didn't.
<icon src="img/logo.png" />
这种方法是我认为它应该起作用的方式,但它没有。
<icon src="img/logo.png" />
cordova version 4.0.0
科尔多瓦版本 4.0.0
回答by ViktorE
I've had the same issue (icon changed back to the default one, even when I had my paths set correctly), changing the line
我遇到了同样的问题(图标改回默认的,即使我的路径设置正确),改变行
<preference name="prerendered-icon" value="true" />
in config.xml from true to false solved the problem for me.
在 config.xml 从 true 到 false 为我解决了这个问题。
回答by walt
Using the Hook from this websitedoes the trick for me.
This Hook is just a JavaScript which is executed during (time of execution can be configured) the build process. This is a great way to keep the content in the platforms
/android
directory generic and no modification of configuration files is needed.
使用这个网站上的 Hook对我来说很有用。这个 Hook 只是一个 JavaScript,它在构建过程中(可以配置执行时间)执行。这是将内容保持在platforms
/android
目录中的通用方式并且不需要修改配置文件的好方法。
PS: Use simple console.log()
commands in the Hook in order to see what exactly is done during the build (in the CLI).
PS:console.log()
在 Hook 中使用简单的命令来查看构建期间(在 CLI 中)究竟做了什么。
回答by Elixander Chen
My Cordova version is 4.2. However I am testing in Android.
我的 Cordova 版本是 4.2。但是我正在Android中进行测试。
During build, phonegap copies the icons from the www/res/icons/ios folder into the ant-build's android res folder, so the custom icons are never used and always replaced by the default.
在构建过程中,phonegap 将 www/res/icons/ios 文件夹中的图标复制到 ant-build 的 android res 文件夹中,因此自定义图标永远不会被使用,并且总是被默认替换。
I suggest performing a cordova build --verbose and thoroughly going through the console log and see if it's misbehaving in anyway.
我建议执行 cordova build --verbose 并彻底查看控制台日志,看看它是否有任何行为不端。
Good luck!
祝你好运!
回答by meaku
It's an open issue: https://issues.apache.org/jira/browse/CB-2606Sadly that's not the only thing not working with cordova atm...
这是一个悬而未决的问题:https: //issues.apache.org/jira/browse/CB-2606可悲的是,这并不是唯一不能使用cordova atm 的问题...
But you could use this hook (which was linked to the issue) to get the functionality right away: https://gist.github.com/apla/6179863
但是你可以使用这个钩子(与问题相关)立即获得功能:https: //gist.github.com/apla/6179863
回答by Rohit Aggarwal
I think you should use the latest version of the phonegap and then give a try.
我认为您应该使用最新版本的phonegap,然后尝试一下。
http://cordova.apache.org/docs/en/3.2.0/config_ref_images.md.htmlBy this we have to not hard code anything in platforms folder of the project.
http://cordova.apache.org/docs/en/3.2.0/config_ref_images.md.html通过这个,我们不必在项目的平台文件夹中硬编码任何东西。
回答by vee
My Cordovaversion is 3.5.0-0.2.7.
It works but it requires set of icons. I'm testing with Andoid. Reference (Document) here
我的Cordova版本是3.5.0-0.2.7。
它可以工作,但需要一组图标。我正在用 Andoid 进行测试。参考(文档)在这里
<icon src="www/res/icon.png" />
<platform name="android">
<icon src="www/res/android/ldpi.png" density="ldpi" />
<icon src="www/res/android/mdpi.png" density="mdpi" />
<icon src="www/res/android/hdpi.png" density="hdpi" />
<icon src="www/res/android/xhdpi.png" density="xhdpi" />
</platform>
I put those icons in to res folder which is located in /www folder.
我将这些图标放入位于 /www 文件夹中的 res 文件夹中。
Now, for your IOS. It should be the similar. (I cannot confirm. I have no IOS SDK.)
现在,对于您的 IOS。应该是类似的。(我无法确认。我没有 IOS SDK。)
<icon src="www/res/icon.png" />
<platform name="ios">
<icon src="www/res/ios/icon-60.png" width="60" height="60" />
<icon src="www/res/ios/[email protected]" width="120" height="120" />
<!-- and more.. (please follow the reference)-->
</platform>
Uninstall your app in emulator, or device and try again.
I hope this help. Good luck.
在模拟器或设备中卸载您的应用程序,然后重试。
我希望这会有所帮助。祝你好运。