xcode and iPhone simulations show weird top grey bar behind views after navigation, how to remove them? - ios

I am trying to update an old Storyboard and viewControllers. in Interface Builder, my viewControllers has the following grey bar that I do not know how and why they are appearing, they were not there previously:
These are also visible when I try to simulate my apps in the iPhone simulator as follow:
When I start my app, the views are stretched with a tiny view of this space as follow:
However, when I start navigating to other viewControllers the space is visible as shown in the previous screenshot.
Any idea of how to stretch my views all the way to cover these areas?
I am currently using swift. The navigation is being done using Storyboard Segue.
Thank you.

This is just the storyboard showing the way the screen will be presented, that grey bar represents the view that will be behind that view controller. This kind of presentation is called modal (page sheet or form sheet) the two have different effects on iPad
Code Fix
To fix this, change the modalPresentationStyle to overCurrentContext on the view controller you're going to present. So in code do viewControllerToPresent.modalPresentationStyle = .overCurrentContext
Storyboard Fix
in storyboard select the segue (the line linking the two screens) and then on the far right menu select the item 3rd in from the right, you should see a section called presentation, change it to Current Context.

Related

UISplitViewController in UITabBarController - SplitView Navigation Bar Glitch / Bug or me doing something wrong?

QUESTIONS AT THE END OF THE POST
PROBLEM: I discovered a strange behavior of UISplitViewController when embedding it in a UITabBarController. The setup is quiet simple and can be reproduced without any coding. Create a StoryBoard based app and drag a UITabBarController onto the StoryBoard and make it the initial view controller. Then drag a UISplitViewController onto the board and make it an item of the UITabBarController. Embed the UISplitViewControllers detail view controller in a UINavigationController as well. Finally, set the background color of the master and detail view controllers to something noticeable.
The StoryBoard should look like this:
Step 1: Run the application on an device which can show master and detail at the same time (e. g. iPad or big screen iPhone). You should notice that the master is not extending under the bars and instead, the background of UISplitViewController shines through.
Step 2: Rotate the screen to portrait so the master gets collapsed. Swipe in from the side to reveal the master. At this point, both navigation bars are showing the correct background color.
Step 3: Rotate the screen back to landscape. Now the detail has the background of the UISplitViewController and the master is showing the correct color.
FINDINGS:
On start, the tableview of the master is not extending under the navigation bar.
When and only if revealing the master in portrait mode and then rotating back, the glich changes so that now the master extends under the bars and the detail does not anymore.
If not revealing the master in portrait, you can rotate as many times as you want without changing the behavior
It only happens on devices which can show master and detail at the same time
It only happens when embedding a UISplitViewController in a UITabBarController
QUESTIONS:
Why are master and detail not expanding correctly under their navigation bar?
Why does this only happen on iPad/iPhone Plus and not on regular iPhones (there everything works exactly as expected)?
Is there any fix I could apply to make this work on iPad?
Is there a better design approach than having a TabBar with a master-detail flow embedded? For me a TabBar just seems right to switch between different types of content in my app and I don't want to have a full width tableview on iPads. The SplitViewController also seems to be the right approach to display my content...
5 Month later there is still no solution for this. Moreover, as I was stumbling across this issue once again while developing another app, I found this old post from 2015 having the same issue: Navigation bar for split view controller is darker when inside a tab bar controller
So I guess Apple has no intention on fixing their own controllers and we developers are screwed. The only way we can have a UITabBar at the bottom while showing a UISplitViewController above with proper translucent UINavigationBars is to implement our own container view controllers.
I finally solved the issue by using a plain UIViewController with a UITabBar pinned to the bottom while using the UIViewController containment API to show/hide my UISplitViewControllers.

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]

Not able to see tab bar controller

I am working on Xcode 5 and have embedded a tab bar controller to a Master-Detail application templates MasterViewController. But for some reasons the tab bar is not visible. A tab bar should be visible in all the screens connecting the Navigation Controller but that cannot be seen. I have already coded lot of functionality in my application using Master-Detail view controller and now my application requires the functionality of building a tab bar controller.
I have looked for ways of resizing the size of table view in the MasterViewController so that tab bar is visible. But I am not sure of how to resize it, as like normal table views this table view does not give markers to resize it.
I have tried changing the streching setting by of the table view and changing its height. But it does not help.
Please help with your ideas around this. I am extremely thankful for your time.
Regards,
Sameeksha
In the storyboard builder, when selecting the related UIViewController, there are a few parameters used to make the preview, you might by accident turned off some features.
In your storyboard, select one of the view controllers, go to Attribute Inspector (Option + Command + 4) and under Simulated Metrics set the value of Bottom Bar to Inferred if it is set to none or any other values.

View Controller in the "More" tab doesn't rotate, but it will if it's on the home row.

I have an app built in storyboard that needs to support landscape mode in just one view controller. I decided to support iOS 6 after some issues with supporting iOS 5 and running iOS 6 on my phone. I used this Stack Overflow answer: https://stackoverflow.com/a/12505461/1050388 but I'm still seeing a weird quirk. (For those interested, my controller scheme is Tab Controller -> Navigation Controller -> TableViewController -> UIWebView. The UIWebView is the only VC I need to rotate.)
I blocked all but one VC from turning, but that VC is in the "More" tab. I initially had a quirk where this "More" VC would change orientation to landscape when rotated and then any subsequent VC would be in landscape, but I found this (https://stackoverflow.com/a/12526152/1050388) and creating a category for UINavigationController helped to solve that issue.
However, when I navigate to that tab in the "More" list, and turn the VC, it doesn't rotate. But when I click "Edit" and move that tab to the home row of the initial 4 tabs, it rotates just fine. If I move it back, it doesn't rotate. Anyone have an idea why this is happening?
I believe the problem stems from the fact that the More navigation controller is generated dynamically by iOS and is read-only.
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITabBarController_Class/Reference/Reference.html#//apple_ref/occ/instp/UITabBarController/moreNavigationController
It would be great if the technique of using a custom category would work here but based on your experience I guess it doesn't.
I also need better control of orientations for More tab views. Please post anything you come up with. Thanks.

"Slide" segue between UITabBar views

My iOS 5 app uses storyboarding with a UITabBarController. There are three "tabs" each displaying a view controller which has been linked using a relationship back to the UITabBarController. At the moment each view controller appears when you tap the relevant tab, as expected. However, for a more gracious transition I would like to slide the view controllers on and off screen.
By way of example, if I am currently on Tab 0 and then select Tab 1 the view controller on screen (for Tab 0) should slide off to the left-hand side of the screen, and the new view controller (for Tab 1) should slide on from the right-hand side of the screen.
I have been able to achieve this behaviour using a custom UIView as the tab bar but would like to know whether this is possible with a custom segue in storyboarding, as that would certainly save a lot of coding (and also would keep things a fair bit neater in the project)?
Thanks in advance for any assistance.
I am trying to do the same thing.
Unfortunately I think the relationship segue does not allow any customization as it just connect tab bar and the tab bar items together, and not a transition.
My guess is we have to do the transition ourselves when the view appeared.

Resources