xmartlabs / XLPagerTabStrip

Android PagerTabStrip for iOS.
MIT License
6.98k stars 1.33k forks source link

Autolayout doesn't work in child's UIScrollView #408

Open timqzm opened 7 years ago

timqzm commented 7 years ago

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 commented 7 years ago

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

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

Abdul-Hannan commented 7 years ago

facing the same issue. @timqzm , any fix ?

timqzm commented 7 years ago

@Abdul-Hannan no ☹️

mud18 commented 6 years ago

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

bhargav6744 commented 1 year ago

same issue ++