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

Is PageTabBarController possible to dynamicly arrange view controllers? #608

Closed
HowardCsie opened this issue Nov 21, 2016 · 13 comments
Closed
Assignees

Comments

@HowardCsie
Copy link

I want to insert or delete view controllers corresponding to user operation.
Is it possible?
The error message popped out while doing so.
The number of view controllers provided (3) doesn't match the number required (1) for the requested transition

@daniel-jonathan
Copy link
Member

Have you tried this function:

open func setViewControllers(_ viewControllers: [UIViewController], direction: UIPageViewControllerNavigationDirection, animated: Bool, completion: ((Bool) -> Void)? = nil)

It allows you to set the Array of UIViewControllers.

@HowardCsie
Copy link
Author

yes, I have tried.
I initialized a PageTabBarController with one root view controller,then i used that function to set three UIViewControllers (Array). I got that error message above.

@daniel-jonathan
Copy link
Member

Okay, I will take a look. I am planning to update the PageTabBar this week, so I will investigate today to help you out, and then release a new PageTabBar. Thanks :)

@HowardCsie
Copy link
Author

Thank you very much.I'll be waiting to hear from you.

@daniel-jonathan
Copy link
Member

Hey, I didn't forget about this issue. I will be able to focus on it within the next couple days. Sorry for any delays.

@HowardCsie
Copy link
Author

Thank you very much!!!

@asyl
Copy link

asyl commented Feb 4, 2017

the same error The number of view controllers provided (3) doesn't match the number required (1) for the requested transition appears again.

@asyl
Copy link

asyl commented Feb 6, 2017

Hi, I need your help! I can't rewrite the amount of viewControllers with method

 open func setViewControllers(_ viewControllers: [UIViewController], direction: UIPageViewControllerNavigationDirection, animated: Bool, completion: ((Bool) -> Void)? = nil)

@daniel-jonathan
Copy link
Member

@asyl Yes, this is in the queue to fix. I was working on launching Motion. Will be updated soon.

@asyl
Copy link

asyl commented Feb 6, 2017

For reference
I found the way how to add dynamically view controllers.
First, redefine property viewControllers of PageTabBarController with your viewControllers.
Second, use

open func setViewControllers(_ viewControllers: [UIViewController], direction: UIPageViewControllerNavigationDirection, animated: Bool, completion: ((Bool) -> Void)? = nil)

to show the page you want. Simply:

pageTabBarController.viewControllers = viewControllers
pageTabBarController.setViewControllers([viewControllers[0]], direction: .forward, animated: true)

@daniel-jonathan
Copy link
Member

@asyl Thank you for sharing. I am working on an update to simplify switching view controllers. Your reference is very helpful :)

@daniel-jonathan
Copy link
Member

You can now use the selectedIndex property to select a tab in Material 2.6.2. For example:

pageTabBarController.selectedIndex = 3

Thank you!

@HowardCsie
Copy link
Author

@DanielDahan Thanks a lot. I 'll try it later :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants