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

example of how to add it to my custom ViewController #30

Open
ghass64 opened this issue Oct 18, 2016 · 5 comments
Open

example of how to add it to my custom ViewController #30

ghass64 opened this issue Oct 18, 2016 · 5 comments

Comments

@ghass64
Copy link

ghass64 commented Oct 18, 2016

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 ?

@dp4dileep
Copy link

same problem

@EndouMari
Copy link
Owner

Do you want to use the TabPageViewController to the RootViewController?

@janaraj
Copy link

janaraj commented Nov 29, 2016

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

@3bdelsalam
Copy link

3bdelsalam commented Feb 27, 2017

@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)
))

@h36ahmedUW
Copy link

`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!

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

6 participants