Constrain pin to top layout guide not enabled - ios

I am trying to pin a UILabel to the top layout guide but the option does not seems to be enabled.
All my other views on the same controller has such option. Anyone knows what might be the cause?

I got it resolved by shifting the hierarchy down such that it is not the top element under the view on the storyboard scene.
Weird behaviour, anyone knows what the intention behind this?

Related

Why did I pass the auto layout check after I uncheck the content layout guide

I am new to IOS development and I am trying to learn scroll view.
I followed the tutorial online and drag and drop the scroll view onto the view controller, and I set the constrains for scroll view.
Contraints
After did this, I got error.
Error
I searched online and one solution is to Uncheck the "content layout guide". Solution
However, that solution page did not explain why this works. I want to know thoroughly why did this uncheck action work rather than just know uncheck it and that's it; i.e, does not know anything in deeper detail.
I hope anyone can help me know the detail about this solution. Thank you so much and Appreciate it.
The original problem was not a problem. A scroll view that uses autolayout has no content size until you give it content and pin it to the scroll view’s content layout guide. The storyboard is right to tell you that. You made that impossible by taking away the content layout guide.

Safe areas on iPhone X wrong

I have a pretty complex app, that causes the safe areas on an iPhone X to be wrong (pushed down).
This screenshot is from a storyboard. It's a container view aligned to the bottom anchor of the Safe Area Layout Guide.
Everything looks fine there and produces the correct result in an empty, new project.
But as soon as I instantiate and push the view controller in the original app, the result is this:
What could cause the safe areas to be distorted?
The property additionalSafeAreaInsets is definitely not set anywhere in the app. I've played around with a couple of other UIViewController properties, but nothing seems to change this.
Thanks!
Please share constraint layout view for your button to get proper/exact solution to your problem.
Here I had same problem.
I had added another view as a subview (gray view) in a main view and moved my button in it. I enabled the safe area layout guide for both main view and gray view.
Safe area layout for gray view safes my button inside safe area.
iPhone X, Layout Preview:
Hope this may help you!
Click on the View(which contains your button) and then check Safe Area Layout Guide
So to perfectly answer my original question:
What could cause the safe areas to be distorted?
Turns out a totally different part of the app was modifying the size of the parent view controller's view.

iOS Universal App Layout Issue

Please see the attached screenshots of the app running - as you can see there is an area at the bottom of the iPhone screen that is not used. The same area of the iPad detail is however. I know there must a bar somewhere I need to hide but I can't find anything amiss.
I have a UITabBar controller as my root VC, which has a tab that leads to the UISplitViewController. As far as I am aware, the UISplitViewController is being used in the standard form.
Can anybody point me in the right direction. I am not sure what information to post, so please ask if you need more info.
Thank you all for your help. In the end though, the solution was fairly simple! I checked the Extend Edges Under Top Bars and Under Bottom Bars options for the UISplitViewController and voila!]1
simple solution
open storyboard
select ur viewcontroller
change wAny hAny
preview ur viewcontroller in iPad/iPhone and all devices u needed
and rotate ur preview screen.
your How to solve this?
Review Debugging Tricks and Tips section of the Auto Layout Guide
Compare storyboard with actual results - does your storyboard contain the same issue (most lightly not).
Review the constraints you have set for the view in question.
Check your constraints for the size classes in view controller with the view in question.
Add an IBOutlet and instance variable for the bottom constraint of the view in question and set breakpoints. Implement any/all of the methods in the UIContentContainer protocol to see what is happening with the constraint and the current class size.
6.Implement - viewWillLayoutSubviews to see any frame changes.

Extra space on top and bottom of Init View Controller

I have a swift app I have been working on for some time now. I noticed that my init view controller has extra space at the top and the bottom of the view, so much that it allows me to pull up and down on the first view and let go and have it spring back into where it was. I removed all my constraints thinking I had an issue with them, but it's still done the same thing. The size class is set to any any, and all my graphic fit inside the view, yet I still an able to pull up and down.
I also made sure my view, wasn't a scroll view, it's not.
I looked around for similar issues, but couldn't find anything like this.
Thanks for the help!
Here is what my view looks like in IB
When I run the app.
Showing the amount I am able to pull it down from the top.
If you remove all of your constraints, and the storyboard is set to use auto layout, it usually won't show up correctly, as you have seen. You will have to add the constraints to each element in your view controller. To do that, you can control click on each and drag it where you want to connect a constraint. Or, use the pin and align buttons in the bottom right corner of the storyboard view.
There is a good tutorial from apple that I suggest you read. It will help you with the basics of using auto layout. Another option would be to not use auto layout. To turn it off in the Storyboard, go to the file inspector and uncheck the box "Use Auto Layout".

UIScrollView in NavigationController ignores top layout guide

I've seen similar questions about custom transitions(iOS7 Custom ViewController transition and Top Layout Guide and Navigation controller top layout guide not honored with custom transition), but I have problem even with regular push. I'm using latest Xcode available now (Version 5.1.1 (5B1008)).
Here is my storyboard:
Problem occurs in 3rd VC
Here is 3rd VC settings:
My 3rd controller's layout is follows:
UIView
UIScrollView
InnerUIView
Other views
I've tried two different ways to create a layout:
Ignore top layout guide (it has y = 64 because of nav bar)
I pinned scrollview's top to container (ignoring topLayoutGuide), manually set height of inner view and pinned its top to scrollView. It gave me the following result:
Looks fine, but why do I need top layout guide then?
Use topLayout guide
ScrollView's top is pinned to topLayoutGuide.
As you can see, top button moved down and view looks strange.
What is the right way of creating such layouts?
I had the same problem and spent hours pulling my hair out.
My container view inside scrollview had weird top offset despite the fact that it had top constraint set.
The workaround I've found - you have to uncheck Adjust Scroll View Insets in your controller layout options
that way content view (in my case) stays pinned to scrollview's top.
Unfortunately I couldn't find any reasonable explanation of this behaviour.
In my case, Xcode 7 and 8, I had to uncheck the 'Adjust Scroll View Insets' for the Views in my Navigation View Controller. And yes, it wasted too much time before I figured this out.
EDIT: Apple has found out that we have found a solution, so they managed to break this again in XCode 9 and 10, to keep us developers pulling our hair. Haven't found a solution yet.

Resources