Xlpagertabstrip: When pager loads for the first time view in first childViewController leaves space from both side for the first time.

Created on 30 Dec 2019  路  4Comments  路  Source: xmartlabs/XLPagerTabStrip

when pager loads tableview in the first child view controller leaves space from both sides but if I switched tabs then it acquires the screen as I wanted.

here is the screenshot of a simulator for understanding:
Simulator Screen Shot - iPhone 6s - 2019-12-30 at 12 53 26

And after switching tabs and as expected:
Simulator Screen Shot - iPhone 6s - 2019-12-30 at 12 56 57

my whole setup is normal tableview has nothing done in that its just a view and
here is XKPager setup

    settings.style.buttonBarBackgroundColor = appBlueColor
    settings.style.buttonBarItemBackgroundColor = appBlueColor

    settings.style.selectedBarBackgroundColor = appBrownColor

    settings.style.buttonBarItemFont = UIFont.appRegularFontWith(size: 16)

    settings.style.selectedBarHeight = 4.0
    settings.style.buttonBarMinimumLineSpacing = 0

    settings.style.buttonBarItemTitleColor = .black
    settings.style.buttonBarItemsShouldFillAvailableWidth = true

    settings.style.buttonBarLeftContentInset = 0
    settings.style.buttonBarRightContentInset = 0

    changeCurrentIndexProgressive = { [weak self] (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in
        guard changeCurrentIndex == true else { return }
        oldCell?.label.textColor = self?.oldCellColor
        oldCell?.label.font = UIFont.appRegularFontWith(size: 16)

        newCell?.label.textColor = .white
        newCell?.label.font = UIFont.appMediumFontWith(size: 16)
    }

   override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
    let child1 = UIStoryboard(name: "Home", bundle: nil).instantiateViewController(withIdentifier: "childViewController1")

    let child2 = UIStoryboard(name: "Home", bundle: nil).instantiateViewController(withIdentifier: "childViewController1")

    let child3 = UIStoryboard(name: "Home", bundle: nil).instantiateViewController(withIdentifier: "childViewController1")

    return [child1, child2, child3]
}

Xcode version: 11.2.1
swift version: 5
ios deployment target: 10.0
XLPager updated

Most helpful comment

I also have a similar issue but in my case the view controller overflows the container.

As a temporary solution I reload the XLPager in the viewDidAppear() method using self.reloadPagerTabStripView() but this results in a repetitive API call which is very disturbing 馃様馃様

All 4 comments

I also have a similar issue but in my case the view controller overflows the container.

As a temporary solution I reload the XLPager in the viewDidAppear() method using self.reloadPagerTabStripView() but this results in a repetitive API call which is very disturbing 馃様馃様

I also have a similar issue , and use
self.reloadPagerTabStripView()

@harshpanchal-silverwing rather than including self.reloadPagerTabStripView() in viewDidAppear() reload you pagerstripview in viewWillAppear like

override func viewWillAppear(_ animated: Bool) {
    setupNav()
    self.reloadPagerTabStripView()
}

this will solve the repetitive API call issues.
Thanks for the solution.

Managed to solve the issue on my side by using this,

DispatchQueue.main.async {
self.moveToViewController(at: 0)
}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ariavm95 picture Ariavm95  路  4Comments

nikhil191090 picture nikhil191090  路  5Comments

bishalg picture bishalg  路  5Comments

Mohammed-Eliass picture Mohammed-Eliass  路  4Comments

SwiftyGuerrero picture SwiftyGuerrero  路  6Comments