Doesn't show content viewcontroller inside of viewPager
import LZViewPager
class rechargeViewController: BaseViewController, LZViewPagerDelegate, LZViewPagerDataSource{
@IBOutlet weak var viewPager: LZViewPager!
private var subControllers:[UIViewController] = []
override func viewDidLoad() {
super.viewDidLoad()
let vc1 = UIViewController.createFromNib(storyBoardId: "prePayTypesViewController")!
vc1.title = "PREPAID"
let vc2 = UIViewController.createFromNib(storyBoardId: "dthViewController")!
vc2.title = "DTH"
let vc3 = UIViewController.createFromNib(storyBoardId: "landLineViewController")!
vc3.title = "LANDLINE"
let vc4 = UIViewController.createFromNib(storyBoardId: "broadBandViewController")!
vc4.title = "BROADBAND"
let vc5 = UIViewController.createFromNib(storyBoardId: "postPayViewController")!
vc4.title = "POSTPAY"
let vc6 = UIViewController.createFromNib(storyBoardId: "autoViewController")!
vc4.title = "AUTO"
subControllers = [vc1, vc2, vc3, vc4, vc5, vc6]
viewPager.hostController = self
viewPager.reload()
}
func numberOfItems() -> Int {
return self.subControllers.count
}
func controller(at index: Int) -> UIViewController {
return subControllers[index]
}
func button(at index: Int) -> UIButton {
//Customize your button styles here
let button = UIButton()
button.setTitleColor(UIColor.black, for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 16)
return button
}
func widthForButton(at index: Int) -> CGFloat {
return 130
}
func willTransition(to index: Int) {
print("Current index before transition: \(viewPager.currentIndex ?? -1)")
}
func didTransition(to index: Int) {
print("Current index after transition: \(viewPager.currentIndex ?? -1)")
}
func didSelectButton(at index: Int) {
print("Current index before transition: \(viewPager.currentIndex ?? -1)")
print("Current index after transition: \(index)")
}
}
Facing same issue don't know why
You can use collection view with paging enabled to get this type of paging view setup.You must use two collection view one for tab bar, another one for show child view controller(Content view). You don't need Library.
You can use collection view with paging enabled to get this type of paging view setup.You must use two collection view one for tab bar, another one for show child view controller(Content view). You don't need Library.
Definitely will try, good idea
It works fine for me
@JegaJegatheesh @vishvabhatt Sorry for my late reply. Did you set up delegate and dataSource like this?
viewPager.dataSource = self
viewPager.delegate = self
I didn't setup....I achieved it by another way..Anyway Thanks to remind!