xcodexamarin.iosautolayoutconstraintshorizontalscrollview

Why Is My Set Up Cutting Off My Constraints To Margins?


I'm working from a storyboard connected to a UIViewController as such:

enter image description here

UPDATE:

The Problem Seems to be that my constraints do not pin to margins. Here are my constraints pinning to the bottom.

enter image description here

Here is how that translates to different devices. enter image description here enter image description here

I have messed with the various size settings shown in the second to last picture. I will try a more systematic approach to changing these if someone isn’t able to very easily detect why this is occurring. It seems unrelated to the Page Control and more related to page sizing

Project Github HERE

Note again, this is the exact same problem I get even when creating the view controller in the method used at: HERE I chose the code used as opposed to the code at the link only because I had already coded this and they were identical in issue, I have become aware sense then that this is a more complicated way to accomplish this though. The issue is recreated perfectly with a simple constraint to the bottom.


Solution

  • There are many issues with your code / storyboard, but I think the problem you're complaining about is here:

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        for view in self.view.subviews {
            if view is UIScrollView {
                view.frame = UIScreen.main.bounds // *
            } else if view is UIPageControl {
                view.backgroundColor = UIColor.clear
            }
        }
    }
    

    Remove the line that I've commented.

    (If you also change the color in the last line to .red, just as an experiment, you will be able to see the page control, and you'll see that the text view is behaving consistently on different sizes of device.)