vtourraine / AcknowList

Acknowledgements screen displaying a list of licenses, for example from CocoaPods and Swift Package Manager dependencies.
MIT License
807 stars 60 forks source link

Customisation of cells on AcknowListViewController #13

Closed gerbiljames closed 8 years ago

gerbiljames commented 8 years ago

I've had a think about this one and I'm just not sure about how to do it. I tried subclassing UITableViewCell and using UIAppearance but for some reason UITableViewCells dont support it for most of their properties.

One way of offering this would be to provide a UITableViewCell subclass (AcknowCell) which has a customisation function which can be overridden. My issue with this is how should AcknowListViewController be told to use a custom cell implementation. I don't think we should add any new parameters to the constructors but it would be possible to add a property to AcknowListViewController which specifies which cell class it should use.

What do you think?

vtourraine commented 8 years ago

It’s been a frequent interrogation on the original Objective-C project.

Having a “class” parameter isn’t a well-established UIKit pattern (you can find it in AppKit, for NSControl and NSCell, but that’s not a great example to follow IMO).

I’d prefer to keep the table view controller as simple as possible, while letting the door open to subclassing, if you need to customize something (the cells, the header/footer, etc). So in this case, I would override tableView(:, cellForRowAtIndexPath:), and re-configure the cell from the main implementation, or even initialize a different cell class.

You mentioned UIAppearance, and it might be interesting to investigate that further. I don’t know if we can better support it for this kind of customization. That would seem like a more elegant approach, if possible.

vtourraine commented 8 years ago

Looked into UIAppearance (doc), and you’re right, it’s too limited for table view cells.

gerbiljames commented 8 years ago

You're right about subclassing being the right way to go. I implemented it in my own project and it worked fine apart from being forced to implement some constructors on my subclass which shouldnt have been necessary. This was due to the same irregularity around the init(coder:) constructor which I found when writing the localization tests and will be fixed in 0.3.

vtourraine commented 8 years ago

Speaking of which, time to release 0.3. It should be available now.