TopLayoutGuide spacing set to 0 creates empty space - ios

I am creating UI in xcode. I have added imageView which topLayoutGuide vertical spacing is set to 0. So I think that it should be positioned right under status bar. However it is positioned under navigation bar (which is not even present).
In the same storyboard I have some views that are embed in navigation controller and it is set to transculent=NO. But this view isnt even linked to them. So I dont think that this should be a problem.
Any ideas how to fix this?
Thanks in advance

Related

change in vertical space of top element in viewcontroller

I have a view controller in navigation stack ... whenever after loading the view controller a change happens in vertical space of top element.
I don't understand why it happens ..
I have set top 5 for the top element of the view controller to the superview
I couldn't fix the problem no matter what ... status bar , top bar ,bottom bar,size are inferred
Info.plist I have set viewcontrollerbasedstatusbarappearance as no and I am setting the status bar as light content in app delegate once..
The problem that menioned not happens with all the view controller only with some viewcontroller it happesn
Thanks for any help
I think that you gave constraint like that,
So, change it as per below,
I hope it will work.
First, click on viewController in storyboard.
So, you will see at a right side corner is like this.
After that, Untick Under Top bars checkbox like that,
I hope this will work.

UIView added to ScrollView not fitting full screen with Navigation bar at the top

EDIT: Small update to my issue, what i did as a solution for now was obviously just having my scrollview white. This fixes my issue, but my real curiosity was to why exactly the content view was doing what i explained below. Also still curious to what common practice formatting is when adding a scroll view to a VC with a navigation bar.
So i am a bit confused with what is going on here. I have a VC with a navigation bar at the top and i need to add a Scroll view to it. So when i did that i stretched it to just below the navigation bar at the top of the screen, then added constraints. (I also made the ScrollView background red so i could differentiate it from the content view)
Secondly i added a UIView which i named Content view and i stretched it to the exact same position as the Scroll view. Then added constraints for that as well. (No objects were added yet)
I then ran the app to check how it looked and i noticed that under the navigation bar my there was a big chunk of red, meaning the Scroll view was full screen in the correct position right below the nav bar, but my content view was not.
A couple things i did to fix this was
I extended the Scroll view all the way to the top of the VC, past the nav bar, but when i ran the app i could see red behind the nav bar, which i figured meant it was not right.
I extended just the content view to the top of the VC, but this did not seem right to me either, even though both seemed to fix the problem.
So my questions are:
When adding views in general to a VC with a nav bar at the top should i be extending those views only to the bottom of the nav bar, or all the way to the top of the VC?
I am new to Scroll views as this is my first time dealing with one, am i missing something in this situation? Or doing something wrong?
Your help is greatly appreciated, thank you.
1) Move the scroll view all the way up and beyond nav bar.
2) Have the scroll view match the height of its parent.

navbar dissapearing in preview and simulator when setting constraints

I'm currently following the udemy ios8/swift course and I'm completely stuck on the navigationbar part. I'm thinking it might have something to do with the fact that I'm on a higher version of Xcode, but can't seem to find the solution.
I have to set the constraints for the navbar on 0 on 3 sides so it will be centered and full width in both landscape and portrait mode. When I try to do this, I see a option thats not there on the course (Constrain to Margins). No matter how much I try to adjust the values, the navbar keeps disappearing or moving in the wrong direction. I tried unchecking the constrain to margins function and putting everything on 0, I tried 'resetting to suggested constraints' and lots of other options, but I can't seem to get my navbar look good in both landscape/portrait mode. So basically, what am I doing wrong or is there any other way to do this?
In addition to the three constraints you need to give the navigation bar a height.
Another solution is to add a navigation item to the view controller instead of a navigation bar. A navigation item will auto format a navigation bar at the top of the view.
I've been able to fix it by manually setting the constraints to 0 in the Attribute inspector after Ctrl-dragging to create them first. Not sure if this is the ideal way, but it solved my problem for now.

How to make a UITableViewController subclass respect topLayoutGuide in iOS7?

in my app I have a simple UITableViewController that's just plain Objective-C code, no .xib or storyboard involved. It represents the contents of one tab in a tab bar.
Since iOS 7 its contents are overlapped by the status bar at the top and tab bar at the bottom.
Using only code, how can I make the table view add space at the top and bottom to align with topLayoutGuide and bottomLayoutGuide?
I know about
self.edgesForExtendedLayout=UIRectEdgeNone;
but that seems to simply shrink the table view to not intersect the tab bar and to disable the transparency of the tab bar. Instead I'd like the table view to add some padding.
Thanks!
Update:
I've also tried explicitly setting automaticallyAdjustsScrollViewInsets to YES, but that didn't help either (should be the default behavior anyway).
It seems this is not (yet) supported, at least for programmatically created UITableViewControllers without an UINavigationController that's embedding them.
I checked the position for both layout guides, and at run-time both off-sets read 0 distance from the edges of the screen. Hence automaticallyAdjustsScrollViewInsets won't set the insets correctly.
So now I actually modify my first section header and last section footer manually to add 21 pixels at the top and 50 pixels at the bottom respectively.
Bummer. :-(

Navigation bar View Controller is twice the size as others

I have a multiple View Controllers embedded in Navigation Controller and one of my navigation bars is twice the size(extends down twice as much) as every other one. I want all of these bars to be the same size, but can't find anyway to change the size in Inspector. There are no bar buttons on this Navigation Bar. Any ideas for a quick fix w/o having to rebuild this VC?
Thanks
Default UINavigationBar have a height of 44 points and it can't be changed. I think you have a constraint issue: select your wrong sized UINavigationBar and on the top right corner, in the "utilities", select "size inspector". Then, have a look at the severals constraints, edit and/or delete some.

Resources