XLPagerTabStrip不刷到下一个vc

时间:2018-09-02 11:38:00

标签: ios swift4 xcode8 xlpagertabstrip

我不知道为什么它没有滑动到下一个viewController。相反,它会滑动到空白页,并且标签滑块也不会移动。但是,当我单击选项卡时,它可以正常工作并滑到下一个viewController。真的不确定为什么会这样吗?任何帮助将非常感激。谢谢

import UIKit
import XLPagerTabStrip

class mainProfileViewController: ButtonBarPagerTabStripViewController {

        @IBOutlet weak var scrollView: UIScrollView!
        @IBOutlet weak var contentView: UIView!
        @IBOutlet weak var headerView: HeaderView!
        @IBOutlet weak var barView: ButtonBarView!
        @IBOutlet weak var viewContainer: UIScrollView!

    let grayColor = UIColor(red: 21/255.0, green: 21/255.0, blue: 24/255.0, alpha: 1.0)

        override func viewDidLoad() {

        settings.style.buttonBarBackgroundColor = grayColor
        settings.style.buttonBarItemBackgroundColor =
        grayColor
        settings.style.selectedBarBackgroundColor = UIColor.init(red: 14.0/255, green: 122.0/255, blue: 254.0/255, alpha: 1.0)
        settings.style.buttonBarItemFont = UIFont(name: "AppleSDGothicNeo-Bold", size:15) ?? UIFont.systemFont(ofSize: 18)
        settings.style.selectedBarHeight = 2.0
        settings.style.buttonBarMinimumLineSpacing = 0
        settings.style.buttonBarItemTitleColor = .red
        settings.style.buttonBarItemsShouldFillAvailableWidth = true
        settings.style.buttonBarHeight = 40
        settings.style.buttonBarLeftContentInset = 20
        settings.style.buttonBarRightContentInset = 20

        changeCurrentIndexProgressive = { (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in
            guard changeCurrentIndex == true else { return }
            oldCell?.label.textColor = UIColor(red: 138/255.0, green: 138/255.0, blue: 144/255.0, alpha: 1.0)
            newCell?.label.textColor = .white  
            }

            super.viewDidLoad()
        }

    override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {

        let child_1 = storyboard!.instantiateViewController(withIdentifier: "profilePhotoViewController") as! profilePhotoViewController
        let child_2 = storyboard!.instantiateViewController(withIdentifier: "profileVideoController") as! profileVideoController

        return [child_1, child_2]

    }
}

child_1 ViewController

class photosNewsfeedViewController: UIViewController, IndicatorInfoProvider {

    var itemInfo: IndicatorInfo = "Photos"

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {

        return itemInfo
    }
}

child_2 ViewController

class videoNewsfeedViewController: UIViewController, IndicatorInfoProvider {

    var itemInfo: IndicatorInfo = "Videos"

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {

        return itemInfo
    }
}

0 个答案:

没有答案