EndouMari/TabPageViewController

example of how to add it to my custom ViewController

ghass64 opened this issue · 5 comments

i have HelpViewController which has a custom navigation bar
so i want to add TabPageViewController into it or subclass it , i dont want to push it into the navigation controller
because my HelpViewController is coming from a side menu not a navigation process
is there any way that you can help me ?

same problem

Do you want to use the TabPageViewController to the RootViewController?

Same problem, yes would it be possible to add it as RootviewController

@ghass64 @dp4dileep @janaraj
i faced same problem and i wanted to show it as RootviewController
after some tries i solved it
by using addChildViewController not pushViewController
((
navigationController?.addChildViewController(tabPageViewController)
))

`override func viewDidLoad() {
super.viewDidLoad()

    let tc = TabPageViewController.create()
    let vc1 = UIViewController()
    vc1.view.backgroundColor = UIColor(red: 251/255, green: 252/255, blue: 149/255, alpha: 1.0)
    let vc2 = UIViewController()
    vc2.view.backgroundColor = UIColor(red: 252/255, green: 150/255, blue: 149/255, alpha: 1.0)
    let vc3 = UIViewController()
    vc3.view.backgroundColor = UIColor(red: 149/255, green: 218/255, blue: 252/255, alpha: 1.0)
    let vc4 = UIViewController()
    vc4.view.backgroundColor = UIColor(red: 149/255, green: 252/255, blue: 197/255, alpha: 1.0)
    let vc5 = UIViewController()
    vc5.view.backgroundColor = UIColor(red: 252/255, green: 182/255, blue: 106/255, alpha: 1.0)
    tc.tabItems = [(vc1, "Mon."), (vc2, "Tue."), (vc3, "Wed."), (vc4, "Thu."), (vc5, "Fri.")]
    var option = TabPageOption()
    //option.tabWidth = view.frame.width / CGFloat(tc.tabItems.count)
    tc.option = option
    
    self.addChildViewController(tc)
    
    self.view.addSubview(tc.view)
    
    // Configure Child View
    tc.view.frame = view.bounds
    tc.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
    
    // Notify Child View Controller
    tc.didMove(toParentViewController: self)
    // Do any additional setup after loading the view.
}`

To add to any custom view controller, first create a container view in custom view controller and then create a controller for that container and place the code as you see in the controller for that container. It should work like a CHARM!