White space on bottom iPhone X Swift - ios

I know that another question with same issue is there but the answers didn't solve my problem.
I have tried the solution here but still, I am getting the white space.
My bottom constraints are with SuperView, not bottom layout guide. I have tried expanding the safe area through code but still, nothing worked.
I am using another embedded view controller inside this view.
Update
View hierarchy

Remove "safe Area" in any storyboard ViewController. And then set constraints accordingly like this.

As you are providing target 8.0 support you can just remove safe area and provide simple constraint same as below image then your white space will remove for sure.

Related

Auto-layout constraints to make WKWebView go full screen

I will mention right away that I'm not iOS developer and this is first time I'm messing with it because I was asked to update web application inside iOS WKWebView wrapper.
I managed to load the web app inside iOS app but on iPhone X there is always white space on top and bottom. I just learned about constraints and I heard that this is default safe area behaviour. I'm trying to expand my WKWebView past safe area to go all the way to the top notch and bottom home button so that there are no white spaces. Inside Xcode all constraints for safe area object is set equal to superview, following web view container object set equal to superview. But I still have white spaces on top and bottom.
There is also top "View" object which I think is elsewhere known as superview, which when I click on I see the constraints for it set equal to safe area and I can only keep it set to safe area or web view container which itself is set to superview. I find this very confusing. What am I doing wrong here?
I would appreciate help regarding storyboard and not code related as I don't speak Swift.
EDIT: Snapshots of constraints
Web View Container Object: https://imgur.com/GcRFeL0
If you use storyboard, you can do like this:
select this constraint and at the right panel, you should change the Second item form Safe Area to SuperView like below:
modify the Constant value from 44 to 0, like below:
the same operation to other constraints.

An image view on an Image View xcode

I'm developing an app using Xcode 8.1 and and swift 3.0.
Using storyboard I've expanded an image view to take up the whole view and set a picture to it to be used as a background image (using self.view.background doesn't give the image the same layout).
This works. I have defined the constraints for it plus added 2 textboxes and a button that also have constraints.
Now I try to add a new image on top of the background image, but then I cannot define the constraints for the front-most image view. I get something like this with two errors telling me to define the constraints but when I do nothing happens.
The way it looks you as per the screenshot, you should just give the padding (spacing to nearest neighbour) for left , right and top in your storyboard.
If there are any warnings just set the current constraints to supersede other views. This can be achieved by selecting the warning and then update constraints and check the box apply to all views in container. It should work.
You need to pin the imageView, what constraints have you set so far?
Just set the constraints for the front image view (as on the your screenshot as well). I don't see any problems.
have you set below constrains
1. Top Layout
2. Bottom layout
3. Leading
4. trailiing
5. height
or
horizontal in center
vertical in center

iPhone X - Safe Area does not achieve full-screen experience?

The new HIG for iPhone X available here, specify:
"Provide a full-screen experience. Make sure backgrounds extend to the edges of the display, and that vertically scrollable layouts, like tables and collections, continue all the way to the bottom."
Now I'd like to understand how to accomplish that with Xcode 9 GM, since it seems to me that the only view allowed to extend to the whole screen is the UIViewController root view, and that whenever I try to drag constraints for a view above that, i.e. WKWebView to the root view, the constraints get actually connected to the safe area, leaving both the top and bottom areas empty as displayed in the storyboard here:
Please note the answer here specifies to use the safe area, but that doesn't work because using it results in the following simulator result where WKWebView is NOT extending to the edges of the screen:
Just change your bottom constraint First Item to SuperView
Actually I believe the answer is this: to accomplish full screen we should NOT use safe area support. After I unchecked Safe Area Relative Margins and Safe Area Layout Guide on the view in Interface Builder Size Inspector I got the expected result:
In fact I would say that the idea of Safe Area is that of an area which will for sure not be overlapped by any of the system icons, or rounded borders, full screen is the opposite of it.
This answer is simple and worked for me .. follow these sequences:
1- select the background image and open constraints window
2- uncheck constrain to margins
3- as in picture : select (View) not (safe area) from the small arrow in the corner of edit value rectangle .. apply this for all 4 values
4 - enter value 0 for all 4 values and hit Enter
and Done
I solved problem by setting top and bottom like this. xcode version is 11.6

Why do autolayout constraints in Xcode cause my subview to disappear off screen?

I'm trying to figure out how to use autolayout, and there seems to be a lack of info about it on the internet. I placed a view within my view controller with three buttons inside it. Before I place any constraints, the buttons show up on the preview. However, as soon as I make ANY constraints, the whole sub view completely stops showing up in the preview. I made a constraint to center vertically, and then one to place it 25 pixels from the left edge. It should know exactly where to place it, but still nothing shows up.
Any ideas on why constraints cause my buttons to not show up?
With Autolayouts the constraints should be as clear as possible. You can try by adding size constraints as well as fix(right, top or bottom) constraints if necessary.
When you don't use auto-layout it positions everything manually. When you enable auto-layout it switches this behaviour off so you have an unconstrained object, which is why it dissappeared.
Turns out I didn't have constraints on the size of the sub view, so it didn't know how to center it. I didn't think I needed that because I thought it would default to what it's already at.

ios- Autolayout- add constraint respect to navigation item

I have just started to move my application to autolayout.
I want to give constraint to a label '0' pixel below navigation bar.
I tried but did not found solution.
Here are screen shots.
In storyboard I gave constraint from superview.
In IOS7 it works fine.
But in IOS6 it goes below navigation bar by 64 pixels, as superview starts below navigation bar.
If I could add top constraint for label below navigation bar it will solve the problem. But I cant find how to do it. I searched through few questions. but dint got the answer.
Please help.
Update for iOS 11:
iOS 11 introduces the concept of safe areas, and the burden of container all the content in a visible area is, again, at the hands of the view, rather than a tango of view and controller.
See Apple's documentation here.
When working with storyboards or XIBs, it's as simple as enabling the feature in Xcode. This is backward compatible and should work as expected under iOS 10 and below. In code, you would use if (#available(iOS 11.0, *)) in order to decide whether to set constraints against the safe area guide/anchors or use the legacy guides on older systems.
When using storyboards, you need to add a constraint to the top layout guide. This will take care of your issues, as on iOS6, that is 0pt and on iOS7, it is dynamic. If you are using a nib/xib file, it gets a little more complicated; you need to add the constraint in code. The easiest way to achieve this is to create a constraint with 0 vertical space to top, create an outlet to this constraint in the code and in viewDidLayoutSubviews, update the constant of the constraint outlet to the value of self.topLayoutGuide.length.
You just have to make some modifications in your constraints :
1) Give a height constraint to your label
2) Pin your label to leading view - Horizontal Space Constraint
3) Add a Vertical Space Constraint
3rd step has to be careful [I'm attaching an image for your reference.]
And after doing that, check if the red arrow mark still persist on your View Controller.

Resources