Navigation bar item automatically changes its height and position in storyboard - ios

I have a project which was build in Xcode 8.2 and now when I run it using Xcode 9.2. I am facing problems with the custom navigation title and bar buttons in the view controllers. In my storyboard I have a View Controller and on its Navigation bar I have a custom navigation view with a label used as the navigation title.
Since we cannot add constraints on the navigation view, I have given autolayout for both the view and label. Now when I run the project, the custom navigation title has disappeared. So I opened the storyboard to check what really happened, I was shocked to see that navigation view's origin.y value is changed to some other value, like -44, -88, etc. Now I edited the origin.y value, saved and run the project, but still the view was not seen. So now when I checked back in the storyboard the frame of the view was changed to some other value. I tried creating new custom navigation view, but no luck. This keeps happening and I am really worried. I really appreciate if you guys can give me some information on this issue.
Click to show screenshot of custom view in the navigation bar

Related

White Bar appearing at bottom of each view controller in storyboard but doesn't affect when ran

In my storyboard view these white bars appeared at the bottom of every view. I can't remember what I did when they appeared, the only thing I can think of was that I tried to add a bar button but then deleted it, so maybe that created some sort of bar. However the bar doesn't show up when running the app in the simulator, it just has a visual in the storyboard.
Does anyone know what it is / why it appeared? and also how can I get rid of it. I got rid of a few by changing the view heights and then changing them back, but when trying to do the same in the first view when I clicked the white bar they all appeared again on every view.
Also, I've noticed some are within the view and some are an extension.
This issue is caused by adding a bar button item and then removing it. The fix is pretty easy though. Go to your storyboard and select the View Controller having the issue.
You will then want to go to the Utility area on the right side of your screen. You will see Bottom Bar = Translucent Toolbar. Change that to None and you're good to go.

iPhone X - Hidden status bar pushes Navigation Bar upwards

I'm testing iPhone X behavior using the Xcode simulator. For some odd reason, if I'm hiding the Status Bar the Navigation Bar pushed upwards causing the title to completely disappear and cutting the left and right buttons. This is happening only on the iPhone X.
Illustration:
How can I hide the status bar and keep the Navigation Bar at a visible position?
UPDATE:
Sample project for your convince:
https://drive.google.com/file/d/0B5qJARV-Oc9ra1hvZkpXZm9lRUE/view?usp=sharing
One solution is to embed the navigation controller inside a container view controller which is properly constrained to the safe area.
Just create another view controller and drag a "Container View" from the Object Library. This view has top, bottom, leading, and trailing constraints to the safe area, all with constants equal to 0. If you control-drag from the container view to the navigation controller, you'll get an option to set an "embed segue" which will embed the selected view controller as a child view controller.
I set the status bar to be hidden on the new view controller I created, and it works fine.
This feels like something that UINavigationBar should handle automatically, but this workaround seems like it should work pretty well.
Another note: if you change the color of the navigation bar, you'll also need to create another view above the container view, and change its color to match the color of the navigation bar.
I, for a small app, changed from using a Push to a Modal segue and adding in my own navigation bar. I used Push because it looks good, and already had a Modal for another part, which I wanted to animate differently for style reasons.
For smaller apps this may be the quickest and easiest solution, but my next update I need to use the navigation controller. For that I think I'll switch on the status bar, which is no big deal for me and allows it to work.
I think you need to use "safeAreaLayoutGuide" new update in iOS 11
Apple has provided us with the necessary APIs to get around the unsafe regions of this iphone x. We do this by using the new safeAreaLayoutGuide anchors in our code
safeAreaLayoutGuide

scroll up tableview to hide half of navigation bar and the whole table gets offset

I'm using a UITableViewController embedded in a navigation controller, I've checked the "hide bars on swipe" for the navigation controller in the storyboard. No crazy code, scrollview functions are not overridden, didn't write any code that would offset any views.
When I scroll up the tableview a tiny bit and release it when the navigation bar is half hidden, the whole table gets offset and it's off screen (sometimes the top left corner of the table is visible), then if I scroll up the table view a bit, it's back to its normal position, if I check "adjust scroll view insets" in the storyboard, the whole screen flashes black.
Has anyone encountered the same problem?
p.s. I'm using Xcode 9 beta with iOS 10.3, not sure if this has anything to do with it.
EDIT:
Scroll navigation bar half way
The view after releasing
So I created a new set of TableviewController and NavigationController, and tested it step by step by adding changes to it, it turned out that I had set my navigation bar to be translucent in the storyboard, once I unchecked it the issue was resolved. There's still an unwanted bounce effect if I release the navigation bar at half hidden position, which appears to be the view adjusting the offset, but it's way better than what it was like.
P.S. make sure "Adjust scroll view insets" is checked.
EDIT:
Turns out setting extendedLayoutIncludesOpaqueBars to True also resolves this issue, if you want to keep the navigation bar opaque.

Storyboard / Navigation Bar issue in Xcode

I'm experiencing a bit of a weird issue and I'm hoping someone can point me in the right direction.
In Xcode, using storyboard, I have a view controller that inherits a navigation bar. This is working fine. Where the issue is is that when I add an element to the view controller (ie, UIButton, UILabel, etc) and run the application on my phone, the Y positioning of the element is off by the amount of the height of the navigation bar.
Let's say I wanted to have a UIButton DIRECTLY BELOW the navigation bar, I would have to move it UNDER the navigation bar, to the very top of the view controller on the Storyboard. On my phone it would be directly below (Y positioning) the Navigation Bar.
I'm fairly new to iOS development, so I'm not even sure where to begin. I tried enabling / disabling Auto Layout, which didn't change anything.
Try this:
Click on your view controller, in the Attributes Inspector uncheck the "Adjust scroll view insets" option.

UITabBarController in storyboard hides content of UITabBarItems

I am a beginner using storyboards for iOS. I have been using the tab bar controller to show my content.
When I first implemented the UITabBar I could see all the icons at the bottom of the UITabController in storyboard and I could see the UITabBarItem at the bottom of each UIViewController. Why is there now a blank grey bar? I can't seem to change the content either in storyboard. I tried adding another UITabBarController but got the same problem, it also has a dark grey bar at the bottom. However when I run the app all the icons appear. How do I fix this so I can see the UITabBarItems in storyboard or should I just try updating them programmatically instead?
Showing a tab bar or not is one of the couple of simulated metrics used in Interface Builder. As such they only serve to have an idea of how your controller would look under different conditions but do not really change anything to the actual controller.
Most of the time the default Inferred option will try to deduce from the Storyboard configuration how it should look like. In your case just connect the tab bar controller to your controller through the viewControllers outlet.
In contrast, below you have some View Controller properties that change both how your controller is previewed in Interface Builder and also its actual behavior (for instance try changing Adjusts Scroll View Insets or Extended Edges).

Resources