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
Load View/ViewController from Nib file #162
Comments
What else needs to be controlled? |
Just found that we already have something similar in EZSwiftExtensions.
However it's a bit confusing as I suppose. Also it's not SwiftLint compliant. We should control View/ViewController that will be instantiated by its type, nib should also have the same name, thus it's good practice to have the same name for View class and it's xib. Hm... for ViewController it's not the best approach to always name xib the same as class name. So, perhaps, we should control nib name, class to look up and overloaded owner with owner. |
Yeah, makes sense, personally I don't use storyboards/xibs so you 2 decide |
@piv199 how would you do it? I agree with you 100% Wanna send your Swiftier version of this? let view: CustomView = NSBundle.loadNib("nibName") or let view =NSBundle.loadNib("nibName") as? CustomView |
@piv199 any updates on this? Let me know if you need help! 😉 |
I have this extension for that: |
@piv199 what do you think? |
then I create a manager first: then .. use ViewControllersManager.loginVC.rawValue |
Hm.. makes sense... Also, have something like
@lfarah As for me, I like this 👍 |
|
I don't be able to get Type of UIVIewContreller inside function, any ideas? |
Now it looks like the following
let filterHeaderView = UINib(nibName: FilterHeaderView.className, bundle: nil).instantiateWithOwner(self, options: nil).last as? FilterHeaderView
Not as Swifty as it could be. Should we have an extension for that?
Well I don't actually know yet how it could be more swifty. Could anybody give an example? Something like
let filterHeaderView = UINib.instantiate(view: FilterHeaderView)
- loads nib from nil bundle with class name name, searches for view with passed class and returns it. Or something more controllable.The text was updated successfully, but these errors were encountered: