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

Add option to configure TableView style for storyboard usage #74

Merged
merged 4 commits into from
Oct 5, 2020
Merged

Add option to configure TableView style for storyboard usage #74

merged 4 commits into from
Oct 5, 2020

Conversation

Tobisaninfo
Copy link
Contributor

This pull requests add the option to configure the TableView style in the initializer used by storyboards.

I used the new initializer in my ViewController the following way:

    public required init?(coder: NSCoder) {
        super.init(coder: coder, style: .insetGrouped)
    }

@codecov
Copy link

codecov bot commented Oct 3, 2020

Codecov Report

Merging #74 into develop will increase coverage by 1.11%.
The diff coverage is 100.00%.

Impacted Files Coverage Δ
Source/QuickTableViewController.swift 87.50% <100.00%> (-0.74%) ⬇️
Source/Rows/SwitchRow.swift 100.00% <0.00%> (ø)
Source/Rows/NavigationRow.swift 100.00% <0.00%> (+17.14%) ⬆️

Copy link
Owner

@bcylin bcylin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tobisaninfo thanks much for the pull request.

This lib wasn't designed to use with storybaords so it's a bit tricky. I think the proper solution is to make the table view an @IBOutlet and set view = tableView when func loadView().

One of the simpler approaches for now is to follow UITableViewController by making the table view readwrite:

class QuickTableViewController {
-  open private(set) var tableView: UITableView = UITableView(frame: .zero, style: .grouped)
+  open var tableView = UITableView(frame: .zero, style: .grouped)
}

Then it's much easier to override the table veiw for you needs:

required init?(coder: NSCoder) {
  super.init(coder: coder)
  tableView = UITableView(frame: .zero, style: .insetGrouped)
}

Can you make the changes and see if it works? Thanks.

@Tobisaninfo
Copy link
Contributor Author

Hi Ben,

thanks for your feedback.
I changed my edits to your simpler approach. I tested the changes in my own project and it works good for me.
Please let me know, if I can do anything better.

@bcylin
Copy link
Owner

bcylin commented Oct 5, 2020

Thanks for updating the PR 👍

@bcylin bcylin merged commit aae3367 into bcylin:develop Oct 5, 2020
@Tobisaninfo
Copy link
Contributor Author

Hi @bcylin,

I would like to ask you for a favour. Maybe you heard about the Hacktoberfest (https://hacktoberfest.digitalocean.com/details). It is about open source contribution and doing something good for community and our planet. So I wonder if you might add the label hacktoberfest-accepted to this pull request. This will help me, to achieve the goal of the Hacktoberfest.

Thanks
Tobias

@bcylin
Copy link
Owner

bcylin commented Oct 25, 2020

@Tobisaninfo sure, thank you for creating the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants