-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Cannot override ReusableCellViewProtocol properties to have a custom implementation #14
Comments
I concur; overriding has no effect. |
There was an implementation problem with public protocol ReusableCellViewProtocol: class {
static func reusableViewType() -> AnyObject.Type
static func reusableViewClass() -> AnyClass
static func reusableViewIdentifier() -> String
static func reusableViewSource() -> ReusableViewSource
static func registerReusableView(inTable table: UITableView?, as type: ReusableViewRegistrationType)
static func registerReusableView(inCollection collection: UICollectionView?, as type: ReusableViewRegistrationType)
} By default Owl provide a default implementation which uses storyboard for cells and xib for header/footer view, but now you can override it in your classes. |
Nice! I was implementing it myself as functions already, but thanks for doing this :) |
in fact there still a problem because using methods it calls only the protocol methods not the one in cells. I'm investigating it but any help is welcome. |
I'll try to help; the first and least likely solution being the removal of the default implementations...forcing us to create our own sensible defaults. But like I said, I'll try to help |
I tried messing around a little bit, but due to the nature of Swift's dispatching I'm not sure if this is going to work; currently it works because the other static vars on the protocol are derived from Solutions I tried include writing overridable class functions or non-static protocol functions, all failed with "it not being possible to override declarations in extensions". Arguably 'uglier' solutions include lifting the configuration of the cells one level higher to the I made some messy adjustments in a fork Using the code in that branch I can provide the source using these lines:
Personally I'd just go for removing the default implementation—at least for the 'source'. Maybe there is no reasonable default for where to get the cell's UI from. |
Ok wow, after I posted the above comment I noticed your commit...which is not far from what I was ultimately trying to do in my fork 😄 |
Ehehehe exactly :-) This is the behaviour used to load/dequeue cells and header/footer both for tables and collection views:
You can however this behaviour by setting the following attributes before the adapter (
By default cells or header/footer will use the name of the class itself as However you can still override this behaviour by setting Another interesting property is
The following example load a cell from an external xib with the same name of the class ( let contactAdpt = TableCellAdapter<Contact, ContactCell>()
// instead of load cell from storyboard it will be loaded by
// reading the root view inside the xib with the same name of the class
contactAdpt.viewLoadSource = .fromXib(name:nil, bundle:nil)
// optionally you can also set a custom id
contactAdpt.viewReuseIdentifier = "CustomContactCellID"
// configure...
director?.registerCellAdapter(contactAdpt) |
Cool! Glad you figured it out in the end :) |
Don't get reusableViewSource from cell. Always get from default protocol extension.
The text was updated successfully, but these errors were encountered: