XLPagerTabStrip icon indicating copy to clipboard operation
XLPagerTabStrip copied to clipboard

Autolayout doesn't work in child's UIScrollView

Open timqzm opened this issue 7 years ago • 5 comments

I've set children like this:

    override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
        let child_1 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "LoginViewController")
        let child_2 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "RegistrationViewController")
        return [child_1, child_2]
    }

That's my hierarchy in the first child controller (in the second it is almost the same): screen shot 2017-06-29 at 16 34 32

All constraints have right values, but look wrong. On devices too. screen shot 2017-06-22 at 16 41 37

I've played with this a lot. All autolayout stuff outside scroll views work perfectly. Views inside behave very strange, they change their sizes sometimes, but for example, don't react on changing device in IB ("View as iPhone/iPad...").

P. S.: I'm sure that this behaviour is not a bug of text fields.

timqzm avatar Jun 29 '17 13:06 timqzm

I've found a workaround, but this issue should be still open, I think.

  • centered text fields horizontally
  • provided vertical spacing and heights
  • set fields width equal with root view width with 0.9 multiplier

I'm not satisfied, because I want to have leading space equals 20 and tralling equals 20, not 0.9 of view width.

screen shot 2017-06-30 at 09 55 34 (I'm not a guru of autolayout, i just think Tralling Space to: Superview Equals: 20 has works like Bottom Space from last field to bottom of Scroll View. "Scroll View has ambiguous scrollable content width" error without this constraint)

So it looks ok in IB and on devices/simulator.

screen shot 2017-06-30 at 09 54 27 screen shot 2017-06-30 at 09 54 46

timqzm avatar Jun 30 '17 07:06 timqzm

facing the same issue. @timqzm , any fix ?

Abdul-Hannan avatar Jul 24 '17 09:07 Abdul-Hannan

@Abdul-Hannan no ☹️

timqzm avatar Jul 24 '17 10:07 timqzm

What the hell. Facing same weird issue.

It seems to be the containerView which is adding childController.view needs to be asked to layoutIfNeeded() or layoutSubViews() before adding childControllers

mud18 avatar Mar 15 '18 02:03 mud18

same issue ++

bhargav6744 avatar Oct 11 '22 18:10 bhargav6744