Xlpagertabstrip: Dynamically add view Controllers and tabs based on server data

Created on 29 Mar 2018  路  8Comments  路  Source: xmartlabs/XLPagerTabStrip

please help me...i want add view controllers and tab text based on my server response... there is no fixed no.. how do i do that

Most helpful comment

I have same issue.

we are not able to create dynamic child view in this.
If any body find solution than please help me.
I am stuck in this problem.

All 8 comments

Im currently trying to find a solution for this too.

Like for a UITableView, there is a function to reload the pager.
Just call reloadPagerTabStripView() after you received your data from your server and initialized your UIViewController in func viewControllers(for pagerTabStripController: PagerTabStripViewController)

I have same issue.

we are not able to create dynamic child view in this.
If any body find solution than please help me.
I am stuck in this problem.

This is throwing "Fatal error: Index out of range" when calling reloadPagerTabStripView() function after updating the controllers.
The file and line of crash is:
ButtonBarPagerTabStripViewController.swift -> collectionView(_: UICollectionView, layout: UICollectionViewLayout, sizeForItemAtIndexPath: IndexPath) method's first statement:
guard let cellWidthValue = cachedCellWidths?[indexPath.row]

Just create an EmptyChildViewController.swift:

import UIKit
import XLPagerTabStrip

class EmptyChildViewController: UIViewController, IndicatorInfoProvider {

    override func viewDidLoad() {
        super.viewDidLoad()
        // do nothing
    }

    func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
        return IndicatorInfo(title: "")
    }
}

set empty child view when your data in not ready

override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
        if data.count > 0 {
             // get datas

           return [childVC]
       } 

        let empty = EmptyChildViewController()

        return [empty]
    }

I was able to achieve this, https://stackoverflow.com/a/56563002/9704569

Like for a UITableView, there is a function to reload the pager.
Just call reloadPagerTabStripView() after you received your data from your server and initialized your UIViewController in func viewControllers(for pagerTabStripController: PagerTabStripViewController)

How can you make the dynamically created view controller instance conform to the IndicatorInfoProvider protocol?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ShockUtility picture ShockUtility  路  10Comments

royatv picture royatv  路  10Comments

BasantAshraf picture BasantAshraf  路  13Comments

jhkersul picture jhkersul  路  15Comments

always19 picture always19  路  23Comments