iOS – Custom UinaVigationBar can run on the simulator, but not applicable to released version

I want to gain insight into a problem that I have been trying to solve for the past few hours. I have a custom UINavigationBar being configured in the application: DidFinishLaunchingWithOptions by calling the following method:

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavBar"] forBarMetrics:UIBarMetricsDefault];

When I run my When applying the app (whether in the simulator or on the actual device plugged into the computer), this works well and shows my custom background. However, when I run the release version of the app on TestFlight, it shows Standard light blue navigation bar. After messing up the placement of the setBackgroundImage method, I had no luck. I began to believe that it was related to the difference between “Debug” and “Release” settings, but I had no idea where these settings caused this navigation bar problem. No clue.

Any help or insight into this issue (or how I will debug it) would be greatly appreciated. Thank you in advance!

As mentioned in my comment, when you encounter similar problems, you should Check the name of the image and make sure it is not case sensitive. You may have added an image named navBar, but you are using NavBar in your project. This is the cause of this problem. The emulator is not case sensitive, but the device is.

Either change the code to,

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navBar"] forBarMetrics:UIBarMetricsDefault] ;

I hope to gain insight into a problem that I have been trying to solve for the past few hours. I have a custom UINavigationBar being configured in the application: DidFinishLaunchingWithOptions by calling the following Method:

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavBar"] forBarMetrics:UIBarMetricsDefault];

When I am in When running my app in XCode (whether in the simulator or on an actual device plugged into the computer), this works well and shows my custom background. However, when I run the app’s release on TestFlight When the version is released, the standard light blue navigation bar is displayed. After messing up the placement of the setBackgroundImage method, I have no luck, I began to believe that it is related to the difference between the “Debug” and “Release” settings, but I set these settings to cause this navigation The location of the question is clueless.

Any help or insight into this issue (or how I will debug it) would be greatly appreciated. Thank you in advance!

As mentioned in my comment, when you encounter similar problems, you should check the name of the image and make sure it is not case sensitive. You may have added an image named navBar, but you are using NavBar in your project. This is the cause of this problem. The emulator is not case sensitive, but the device is.

Either Change the code to,

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navBar"] forBarMetrics:UIBarMetricsDefault];

Leave a Comment

Your email address will not be published.