AutoLayout: when to use bottomLayoutGuide vs. “V:[continueButton(50)]|”
I'm having a UIViewController inside a UIPageViewController, where I would like to add a button at the very bottom. I just don't understand the difference between NSLayoutConstraint.constraintsWithVisualFormat("V:[button]|", options: .DirectionLeadingToTrailing, metrics: nil, views: ["button":button]) // works and NSLayoutConstraint.constraintsWithVisualFormat("V:[button][bottomLayoutGuide]", options: .DirectionLeadingToTrailing, metrics: nil, views: ["button":button, "bottomLayoutGuide":bottomLayoutGuide]) // doesn't work The first line adds the buttom at the very bottom, with the second line there is a padding of 50px between the button and the bottom. Does this have to do with the UIPageViewController (which itself is in a UINavigationController)?
The bottom layout guide is useful for layouts where the parent controller has some kind of view that overlays the current view controller's contents. So in your case the UIPageViewController has such a view, which is a UIPageControl view that you may not want to be overlapped, thus if you specify the bottom layout guide as a boundary, your view will pin right above the UIPageControl. That's convenient especially if you depend on such a constraint (that becomes clear in the example I provide below). A UITabBarController also has a bottom layout guide, which is the tab bar's top. This is convenient because most of the times you'll need a constraint to the top of the tab bar otherwise views will be situated underneath it (which may lead to bad user experience [think: If you constrain a tableView to the very bottom (NOT the bottom layout guide) then the last cell may be overlaid by the tab bar, which is certainly bad UX]). So as you can see sometimes it is useful to have the ability to constrain to the bottom layout guide of a view controller where the parent controller's elements occupy space that may not be necessarily good to place a view under. Same goes for UINavigationController, if you have a view controller contained in a UINavigationController, the topLayoutGuide will basically indicate where the UINavigationControllers navigation bar ends, thus it would be useful to constrain any views to that top layout guide otherwise the views will end up underneath the navigation bar. In your case I think you'll be fine constraining your views to the very bottom of the UIPageController's view as views underneath a UIPageControl usually contain images which will not look obfuscated by the UIPageControl (The page control serves more as a visual feedback mechanism than an interaction element). As matt pointed out in his comment by doing something like V:[button]|, you are basically constraining the view to the very bottom of its superview, NOT the bottom layout guide (which is the UIPageControl in your case). On the contrary, V:[button][bottomLayoutGuide] will constrain the view to the UIPageController's UIPageControl, which probably has a default size of 50, which is why there is a difference between those two. I hope that made things clear.
How to register GADNativeAd to auto handle GADNativeContentAd view click in iOS?
gen_bridge_support ignores variadic functions
UISlider default thumbcolor
Olympus Camera Kit: Cannot update exposure compensation value soon after
Trigger an event (tableview reload) whenever a text is in a certain position of a textView in iOS
Populating a UITableView within a UIViewController and changing data source with UISegmentedControl
can't access webView from UiViewController subViews
What is the current Parse email verification regex pattern?
How to send images and videos to server using ASHTTPRequest in ios
how to rearrange array using objective c?
swift - Twitter login button created with no completion block?
AVAnimator Assertion failure in -[AVMvidFrameDecoder advanceToFrame:] 'framebuffer num bytes'
Instagram InstagramCaption not working
Delete sections without scroll down
Facebook Login Button Throws An Error And Says I Cannot Login
In-app purchase receipt validation, “in_app” field empty