Comments (7)
Mmmh could be a very simple addition to do indeed. Care to do a Pull Request?
I think it should be as easy as adding something similar to:
protocol NIBBased {
static var nibName: String { get }
}
extension NIBBased {
static var nibName: String {
return String(describing: self), bundle: )
}
}
extension NIBBased where Self: UIViewController {
static func instantiate() -> Self {
return Self.init(nibName: self.nibName, bundle: Bundle(for: self))
}
}
β¦ + documentation and tests π
Would be a great contribution :)
from reusable.
Nope, I don't think anyone has found the time to implement that yet indeed π
from reusable.
Yep, closed any time.
from reusable.
Has this feature been implemented yet? It doesn't seem like.
from reusable.
Hi @AliSoftware ,
I believe this issue is resolved in pull request #82
from reusable.
Should be once merged indeed, thanks for the PR π just took a look and commented there π
from reusable.
Just realized that all this functionality is already handled for us by Apple: when you call init
on a UIViewController
, it forwards it to the designated init(nibName:bundle:)
with nil
parameters⦠and when nibName
is nil
, iOS automatically searches for a XIB of the same name as the class and use it if it finds one!
This is detailed here in Apple's documentation. See also #82 (review)
That means that given a class CustomViewController: UIViewController { β¦ }
if you also have a CustomViewController.xib
file in your bundle then using let vc = CustomViewController()
will automatically use the XIB for loading the VC without yo needing to specify anything.
Hence I'm gonna close this issue sinceβ¦ there's no need for Reusable here, this is behavior provided by iOS for UIViewControllers already π
from reusable.
Related Issues (20)
- getting error on using cellType(for indexPath:)
- Support for new API introduced on iOS 13
- MKMapView support
- Feature request - allow to use UITableViewCell with custom style
- Swift Package Manager: reusable deployment target warning HOT 3
- SPM xibs (Bundle.module) HOT 1
- Xcode 12.5 warnings HOT 2
- Swift tools version update too high, lower version build failed
- UITableViewHeaderFooterView - Warning with NibReusable
- Sure, go ahead!
- ## Summary
- Feature request - access to root xib view
- Support for reusable UITableViewHeaderFooterView subclasses?
- Privacy Manifest
- Swift 5 Support? HOT 2
- Undefined symbols when compiling for unit tests HOT 1
- Xcode 11 beta 4 compiler error HOT 1
- loadNibContent always loads nib named after base class HOT 14
- is there a way to override sceneStoryboard for StoryboardSceneBased HOT 2
- Swift Package Manager HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reusable.