我不知道为什么它没有滑动到下一个 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 视图控制器
class photosNewsfeedViewController: UIViewController, IndicatorInfoProvider {
var itemInfo: IndicatorInfo = "Photos"
override func viewDidLoad() {
super.viewDidLoad()
}
func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
return itemInfo
}
}
child_2 视图控制器
class videoNewsfeedViewController: UIViewController, IndicatorInfoProvider {
var itemInfo: IndicatorInfo = "Videos"
override func viewDidLoad() {
super.viewDidLoad()
}
func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
return itemInfo
}
}