问题描述
限时送ChatGPT账号..我希望对过去几个小时一直在努力解决的问题有所了解.我有一个自定义 UINavigationBar 正在 application:DidFinishLaunchingWithOptions
中通过调用以下方法进行配置:
I'm hoping to get some insight into an issue I've been struggling to wrap my head around for the past few hours. I have a custom UINavigationBar that is being configured in application:DidFinishLaunchingWithOptions
by calling the following method:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavBar"] forBarMetrics:UIBarMetricsDefault];
当我在 XCode 中运行我的应用程序(在模拟器和插入计算机的实际设备上)时,效果很好,并且显示了我的自定义背景.但是,当我在 TestFlight 上运行应用程序的发布版本时,会显示标准的浅蓝色导航栏.在弄乱了 setBackgroundImage
方法的位置之后,我开始相信这与调试"与发布"设置的差异有关,但我对这些设置的位置一无所知会导致此导航栏问题.
When I run my application in XCode (both in the Simulator and on an actual device that is plugged in to the computer), this works great and my custom background is displayed. However, when I run a release version of the app on TestFlight, the standard light blue navigation bar is showing. After messing with placement of the setBackgroundImage
method with no luck, I have come to believe it has to do with differences in "debug" vs. "release" settings, but I am clueless as to where those settings would cause this navigationBar issue.
对此问题的任何帮助或见解(或我将如何调试它)将不胜感激.提前致谢!
Any help or insight into this issue (or how I would go about debugging it) would be greatly appreciated. Thank you in advance!
推荐答案
正如我在评论中提到的,当您遇到类似问题时,您应该检查图像名称并确保它不区分大小写.您可能添加了名为 navBar
的图像,但您在项目中用作 NavBar
.这就是这个问题的原因.模拟器不区分大小写,但设备区分大小写.
As mentioned in my comments, when you are facing similar issue you should check the name of images and make sure it is not case sensitive. You might have added an image with name navBar
but you are using as NavBar
in your project. That is the reason for this issue. Simulator is not case sensitive but device is.
要么将代码更改为,
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navBar"] forBarMetrics:UIBarMetricsDefault];
这篇关于自定义 UINavigationBar 适用于模拟器但不适用于已发布版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论