XLPagerTabStrip icon indicating copy to clipboard operation
XLPagerTabStrip copied to clipboard

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

Open NikhilGangurde opened this issue 5 years ago • 4 comments

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

NikhilGangurde avatar Dec 30 '19 07:12 NikhilGangurde

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 😔😔

Panchal-Harsh-98 avatar Jan 17 '20 14:01 Panchal-Harsh-98

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

OmarTawashi avatar Feb 09 '20 14:02 OmarTawashi

@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.

NikhilGangurde avatar Mar 04 '20 06:03 NikhilGangurde

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

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

chelvinn avatar Apr 16 '20 03:04 chelvinn