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

How do I create UITabBarController with Viperit! #59

Closed
tharhtet opened this issue Oct 20, 2017 · 2 comments
Closed

How do I create UITabBarController with Viperit! #59

tharhtet opened this issue Oct 20, 2017 · 2 comments

Comments

@tharhtet
Copy link

Could I get the example with UITabBarController with Viperit without NavigationController? Thanks a lot.

@ferranabello
Copy link
Owner

ferranabello commented Oct 22, 2017

Hi @tharhtet, to use a UITabBarController with Viperit I suggest you to subclass UITabBarController and do something like this:

import UIKit

final class AppTabBar: UITabBarController {
    func setup() {
        var modules: [AppModules] = [
            .module1,
            .module2,
            .module3,
            .module4
        ]
        
        viewControllers = modules.map({ mod -> UIViewController in
            let module = mod.build()
            let view = module.router.embedInNavigationController()
            
            // In case you don't need a navigationController
            // let view = module.router._view
            
            return view
        })
    }
}

This is a very simple solution. Of course you could add more configuration to this and inject the dependencies in the setup function or configuration classes or stuff like that.

Anyway, this will get you what you want.

Cheers man!

@tharhtet
Copy link
Author

tharhtet commented Oct 23, 2017

Thanks for your help. :) :)

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

2 participants