Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't show content viewcontroller inside of viewPager #13

Closed
JegaJegatheesh opened this issue Nov 21, 2019 · 6 comments
Closed

Doesn't show content viewcontroller inside of viewPager #13

JegaJegatheesh opened this issue Nov 21, 2019 · 6 comments

Comments

@JegaJegatheesh
Copy link

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)")
           }

}

@JegaJegatheesh JegaJegatheesh changed the title Doesn't show content viewcontrollesr in viewPager Doesn't show content viewcontrolles inside of viewPager Nov 21, 2019
@JegaJegatheesh JegaJegatheesh changed the title Doesn't show content viewcontrolles inside of viewPager Doesn't show content viewcontroller inside of viewPager Nov 21, 2019
@vishvabhatt
Copy link

Facing same issue don't know why

@JegaJegatheesh
Copy link
Author

JegaJegatheesh commented Sep 18, 2020

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.

@vishvabhatt
Copy link

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

@JegaJegatheesh
Copy link
Author

It works fine for me

@ladmini
Copy link
Owner

ladmini commented Sep 24, 2020

@JegaJegatheesh @vishvabhatt Sorry for my late reply.
Did you set up delegate and dataSource like this?

viewPager.dataSource = self
viewPager.delegate = self

@JegaJegatheesh
Copy link
Author

I didn't setup....I achieved it by another way..Anyway Thanks to remind!

@ladmini ladmini closed this as completed May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants