iosswiftxlpagertabstrip

XLPagerTabStrip: Dynamically adding subviews to tab's view controllers wouldn't display except under first tab


XLPagerTabStrip: Dynamically adding subviews to tab's view controllers wouldn't display except under first tab.

Please download the project and run it to see the problem:

https://github.com/farhan101/TheProblemView

First Tab: Under View One tab you can see a spinner added dynamically

First Tab

Second Tab: Under View Two tab same spinner is added but it wouldn't show Second Tab

PS: As you can see in the source code, both view controllers are instances of the same view controller class.


Solution

  • You need to use the parent view's bounds instead of frame while creating ViewToAdd.

    let vu = ViewToAdd(frame: self.view.bounds, yFactor: 2.0)