navigation & tab bars black for a split second right after launch - ios

When launching or bringing my app from the background the navigation bar & tab bar are black for a split second before assuming storyboard defaults.
I feel there is somewhere a property enforcing this but I can't seem to find it.
Found something in the project properties info tab under "Custom iOS Target Properties"
where NavigationBar.Style = Default and NavigationBar.Translucent = NO which seem fine and don't affect the result.
It started happening around the iOS8 upgrade but can't time it very precisely.
Anyone has a clue on what might be causing this? Or where we set

Your view controllers of tab bar should be subclassed with UIViewController not UITabBarViewController. Please check your header file

Related

Xcode Tab Bar Text Glitch

Recently, I have been trying to add a tab bar to an existing project. However, no matter what I do, the text is being cut off. I am simply trying to drag a Tab Bar Controller into the storyboard and setting it as the initial controller.
This seems to only be an issue in this project, as doing the exact same thing in a test project works fine.
Glitched tab bar
Glitched tab bar setup in storyboard
Normal tab bar in test project
Normal tab bar setup in storyboard
I am running Xcode v10.3, and the project is already on the App Store. There is no code attached to the VCs, and as far as I am aware, this should not happen.
What are some possible causes or fixes for this?
Turns out a cocoapod, AMXFontAutoScale, was to blame. I guess it scales the text of tab bars also.

How to solve Google Maps sdk orientation issues using TabViewController

I started an iOS project for iPhone where I thought might want a tab bar. I later decided that I don't want it (I want the extra screen space) and I so I tried to delete the tab bar and set my main ViewController as the initial viewController in storyboard.
This caused a weird error where the device's orientation no longer adjusts properly. For instance, switching from portrait orientation, shown in the picture:
becomes this in landscape:
If you start the app in landscape, it will look fine, but there will be a similar result when you switch to portrait. The bug manifests in the transition between screen orientations.
I've tried the following:
I restored the tab bar and the problem went away. This problem is caused by how I am removing the tab bar and not some other issue.
I searched for other articles dealing with this issue. So far, I've only seen documentation on how to install a tab bar, not how to safely remove it.
I attempted to connect the tab bar to the viewController with an IBOutlet and then set tabBar.isHidden = true. It's a bad hack, but it didn't work anyway. UITabBar has no such member.
I've tried comparing the settings between the tabBar viewController with my desired initial viewController in the Inspector, to see what may be different. Aside from the initial viewController check-box, I don't see a setting that might be causing this.
QUESTION: Is this a settings issue in storyboard (or elsewhere), or is this just a bug? My next attempt at a solution will be to delete the entire storyboard, and then recreate it and connect it back to the viewController. That's a fair amount of work I'd like to avoid if it's unnecessary.
Any help is appreciated. If I find a solution, I'll make sure to post it. Thanks!
UPDATE: I've found a workaround by going to the UI Tab Bar Controller in the Storyboard, selecting tab bar in Tab Bar Controller Scene -> Tab Bar Controller, and then checking the 'hidden' box in the inspector. This has the desired effect of getting rid of the tab bar when the app is running. It's like it's not there.
While this allows me to proceed with the app, the tab bar stuff is unnecessary code lying around in my app that I would like to get rid of.
Since I originally made this post, I've found out through experimentation that the every time I added Google's GMSMapView to a viewController, programmatically or in storyboard, I was having the above orientation issues. My original problem wasn't what I thought it was
I have since tried completely rebuilding the storyboard, viewController and all, but the problem didn't go away. I also tried overloading the orientation methods for the view to no effect.
However, if you are having this orientation problem with Google Maps sdk, imbedding the view controller that contains your GMSMapView in a tab view controller, and then hiding the tab bar (unless you want a tab bar) fixes the orientation issue in my project. It's not pretty, but it works.

Navigation bar not showing in Xcode 7.3

I'm new to iOS development and am having trouble getting the nav bar to show. I've been searching through all the answers to when this question has been asked previously and can't find where my issues is. I'm using a navigation controller. Can any of you see what's wrong with my settings? Much appreciated.
Nav bar settings
Emulator screen shot
Sorry for the lack of pictures. Looks like I'm limited to two.
Select Navigation Controller in the Attributes Inspector check "is Initial View Controller".

iOS Launch Storyboard: How can I change a Tab Bar's tint color?

What I'm doing:
Using a 'launch storyboard'. It's quite simple, and contains a default UITabBarController. I've set the tab bar's 'tintColor' to red in the launch storyboard, as well as in my app. I'm using Xcode 7, iOS 9.
What doesn't work:
The launch screen loads the tab bar using the default blue iOS tint color...! Then after loading, the tint color switches to red when the launch screen storyboard is replaced.
How on earth are you meant to set a tab bar's tint color in a storyboard?
Demo Project: http://s000.tinyupload.com/?file_id=73998115878034693063
The right way to go is to confuse Xcode. Xcode should not know that the launch storyboard that is used is actually a launch storyboard. This way you would be able to set some custom User Defined Runtime Attributes. However, you still would NOT be able to run some custom code...
So... To do this, follow these steps:
Create a new Xcode project
Copy your Main.storyboard into desktop and rename it to CustomLaunchScreen.storyboard.
Add this CustomLaunchScreen.storyboard to the project.
Open your Info.plist file and change key Launch screen interface file base name value from LaunchScreen to CustomLaunchScreen.
Open your CustomLaunchScreen.storyboard. Delete the default UIViewController and set the UITabBarController as your initial view controller.
Open the tabBar property of your UITabBarController and navigate to User Defined Runtime Attributes
Add the tintColor property, set type as Color and set some custom value.
You can also watch a full video tutorial Here
Well thanks to #OIDor for his solution, it is a great hack.
To be clear however, you don't need to do all that. All you have to do is:
Edit the source of your Launch Screen storyboard and change
launchScreen="YES" to launchScreen="NO", this enables you to do the
next part...
Add the user-defined attribute tintColor on the Tab Bar
in the storyboard. This is not permitted by Xcode without the first
step
Hey presto it's all working.
I think I've figured this out.
There are quite a few blog posts online about how Launch Storyboards work, but not a lot from Apple. I found from this blog post which discussed that the launch screen images are captured at runtime from the launch storyboard. Digging into my simulator directory revealed that they were in fact there:
I'm not sure why, but the call to set the UITabBar's tintColor does not fire in time when the launch storyboard has loaded, but setting colors for other values such as the barTintColor property works:
All I can say is this: setting the tintColor on a UITabBar on a view controller in a launch storyboard is not supported. There is something going on behind-the-scenes when the launch storyboard is loaded preventing this from working.
TL;DR: you can't do this with a Launch Storyboard. For a workaround that tricks Xcode into treating your launch storyboard as a regular storyboard, see OlDor's answer.
As an alternative, you could take a screenshot of your app with the tab bar loaded properly, tweak it, and use that in a UIImageView on your launch view controller.
If you want to add just the tab bar without any currently selected tabs, add a UITabBar to your launch UIViewController and style the UITabBarItems to your liking:
This UITabBar has two UITabBarItems which can be styled without adding outlets to their view controllers.

UITabBarController storyboard launch screen - initial tab?

I'm using a storyboard as my launch screen in my app, it contains a UITabBarController with 5 UINavigationControllers. The storyboard doesn't do anything but provide launch screens.
What I want to do is change the default selected tab. I'm currently stuck with this:
And once the actual view controllers load I get this:
As you can imagine it's a bit jarring to have the selection jump like it does. I don't know how to change the tab programmatically since I cannot attach a custom class to anything in a launch screen. Of course, I don't really care if I do it for real, if there's a way to fake it with icons of different colors, that's fine as well, but the system adds that tint to selected icon.
Is there a way to do this with a storyboard launch screen? Thanks.
Don't use a tab bar controller in your LaunchScreen.storyboard. Instead use a normal view controller and add a tab bar, then add tab bar items as required. That seems to be the only way to make a tab bar without any index selected.
Though this question was asked years ago, I've wrangled with it quite a bit and figured out a workaround that I'm satisfied with for my app TimeFinder.
The other answers here have made some good suggestions, but trying to build a replica of TabBarController sounds challenging and unsustainable, and I didn't have much luck with the User Defined Attributes hack mentioned by Akshay Agrawal 1.
Since the problem is ultimately that the wrong item is shown as selected in the launch screen, I decided to hide the selection entirely by changing the selected image tint color to light gray to match the color of the other unselected tab bar item icons 2.
This allowed me to copy and paste my project's top-level view controllers (view controllers embedded in navbarcontrollers embedded in a tabbarcontroller) into the Launch Screen storyboard, delete all the inessential connections and view controllers, and end up with a quality launch screen that makes the app appear to load faster than it does.
Here's my Launch Screen storyboard for reference 3, and here is my app which will have this launch screen update shortly 4.
TimeFinder on the App Store
Use this piece of code in your view will appear method.
yourTabBarController.selectedViewController=[yourTabBarController.viewControllers objectAtIndex:2]

Resources