XLPagerTabStrip
XLPagerTabStrip copied to clipboard
Autolayout doesn't work in child's UIScrollView
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):
All constraints have right values, but look wrong. On devices too.
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.
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.
(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.
facing the same issue. @timqzm , any fix ?
@Abdul-Hannan no ☹️
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
same issue ++