UIViewController leaving Space in bottom - xcode

I am upgrading an old project from iOS4 to latest ios8. There are 2 or three view controllers that don't look right, the navigationbar seem to cover portion of the view and also leaving space in the very bottom. I can't seem to figure it out no matter what I changed for settings by removing/adding topbar/statusbars/bottombars, the xib file looks alright, but not when I run it on simulator or device. Here is a screenshot of what it looks like.

If I see this right, it is an UIImageView holding the backgroundimage... ?!?
I can only guess, but you should change the UINavigationBarStyle from translucent to opaque... That will bring everything lower, where it was supposed to be.

Click on this viewController in Storyboard, uncheck the box for "Under Top Bars" and check the box for "Under Bottom Bars" in the Extend Edges Settings. This should solve your problem!

Related

Why isn't storyboard safe area working correctly on iPhone X?

I'm trying to update my app for the new iPhone X. After reading about the safe area feature and the check box "Safe Area Relative Margins" in each UIObject's "Size Inspector" (ruler tab), I didn't think this would be too bad. However, that feature does not seem to be working for me.
Nothing changed for regular iPhones, which is good, however for the X, the top of my app overlaps the top inset of the phone by a third. Is there any known way to fix this* or something I'm missing?
*By fix this, I mean make it so that my objects start below the outcrop, like the second picture.
What is happening:
Desired Behavior (from https://arstechnica.com/gadgets/2017/11/how-devs-updated-their-apps-for-the-iphone-xs-screen-and-the-notch/):
I too have wasted hours on this. And while I cannot answer your question of why this is broken in Xcode, I can provide a solution.
But first let me note than in Xcode 11.3.1, I experience the same issue in a new project created from scratch.
Set up your storyboard:
On your storyboard, select "Use Safe Area Layout Guides". This will add a safe area to each of your ViewControllers. It will also require you to target iOS9+. You might be able to skip this step though (see step 4 below).
View your storyboard as iPhone 4s.
Fix each ViewController:
Select all views under the top-level view.
Click Editor | Embed In | View Without Inset. This creates a new view and puts all your views inside.
Make this new view expand to the safe area by adding safe area constraints (by control-dragging your new view onto the top level view).
Leading space to safe area
Top space to safe area
Trailing space to safe area
Bottom space to safe area
If you did not opt into using a safe area storyboard above, you may be able to create four equivalent constraints by using the Top Layout Guide, Bottom Layout Guide, and the left/right sides of the top-level view. This may not work in landscape though. And I did not test this.
Set your new view as transparent.
Give your new view a name like "SafeAreaView".
In iOS 11, margins are inset from the safe area. Thus, your zero top margin becomes a 20 top margin — explaining your screen shot. If that's not what you want, set the view's insetsLayoutMarginsFromSafeArea property to false.
In my case modalPresentationStyle = .fullScreen has to be set to the view controller being presented

UITableviewcell width not filling the screen

I don't know if this is a bug with AutoLayout or Xcode but I've realised that if I run my application on a device which isn't the same size as the device in my storyboard, the elements are adopting the incorrect size.
I.e. Selecting View as iPhone SE and running the application on an iPhone 7+ The size of my tableview is the width of an iPhone SE screen, this fixes itself when I reload the view and then it then adopts the width of the iPhone 7+ screen.
Just a note as well the table view doesn't have a fixed width and is pinned to the top, bottom, left and right with 0 spacing and also I'm changing the height of the cells programmatically in code if this could affect it at all as well.
Video: https://drive.google.com/open?id=0B0QLbDLfJn6_YzljUGg4RTUwaTg
Views that come from a xib (or storyboard) have their IB frame values when they are created, before they are added to the view hierarchy. So a case like you describe is probably that something is accessing a view loaded from a xib before it has become part of the layout process and resized.
This would also explain why it's fixed when you go away and come back. The first time, it got the values before they were final, but the second time the values are already final and correct.
Layout code called fromviewDidLoad() for view controllers, or awakeFromNib() or initWith(coder:) for views is the likely cause. Layout code called from viewDidLoad() is especially problematic because it was fine up to iPhone 5s, but would now cause this problem.
It's impossible to say what exactly the issue just from this. From the NSLog statements visible in the video, the issue is whatever code calls that "weather view width". That is being called too early in the layout process. It needs to go in viewWillAppear or viewWillLayoutSubviews to make sure the correct values are ready for whatever calculation is dependent on that. Hope this helps.
I can't seem to recreate this. I would recommend double checking for any updates for Xcode and the Developer tools (softwareupdate --install -a).
Incase you haven't, restart Xcode.
EDIT: Disregard this answer, please read Mike Sand's post.
Try self.view.layoutIfNeeded in viewDidLoad or in viewWillAppear

XCode 6.1.1 UITableView White Spacing Gap

I have been running into some issues where my UITableView after being dragged and dropped into my view controller appears with a sizable white space gap from the top of the element ot the start of the prototype cells. Why does this occur by default and is there a way to remove this? Maybe in the size inspector?
I was having the same issue in 6.3.2 and all I had to do was to go to the ViewController's attribute inspector and uncheck the "Adjust Scroll View Insets" in the layout information section.
Sorry, they won't let me post images, but that solved the frustration for me. Hope it helps someone else.

Put a view in the bottom of another view with a fixed size

Sorry folks if my question seems to be trivial, but xcode drives me crazy.
I don't want anything else, just put a view in the bottom of a view controller in XCode by IB, that has FIXED height even if I rotate device. It stay simply in the bottom and its size stays unchanged.
Autolayout constraints changes its size all the time, hides if I rotate etc. I could not find the settings for this simple problem.
I need this (with fixed size, that does not change/hide when rotating):
How can I do that?
Have you tried unchecking autolayout and playing around with autosizing. Try the below setting . It should work.

View Stretched in Storyboard iOS

can anyone tell me how to get my storyboard back to normal? I'm not sure what I did but all my views seem to be stretched and I can't see the navigation bars at the top of them where I need to make changes to buttons I've put up there.
full size screen Shot of Xcode
I do not know the cause, but I had this problem a while back.
In my situation I had a TabBarController pointing to several navigation controllers. To fix the problem I just deleted the TabBarController and replaced it with a new one.
If you have no TabBarController I would try just replacing the first NavigationController where the stretching takes place and it should fix all subsequent View Controllers.
The simplest solution is to roll back with your version control system.
That happened to me too. As Jeremy responses I had a tabBarController but I fixed by deleting the viewControllers associated to the tabBar, 1 of them was the one causing the problem, it was a Navigation controller wich I've changed the title, so the title was a little big and that did the controller to expand.

Resources