自定义 UINavigationBar 适用于模拟器但不适用于已发布版本

编程入门 行业动态 更新时间:2024-10-08 07:25:44
本文介绍了自定义 UINavigationBar 适用于模拟器但不适用于已发布版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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:关键词]

本文发布于:2023-04-30 23:05:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1400891.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:适用于   自定义   模拟器   但不   版本

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!