An UITreeView implementation from UITableView that Apple missed in its UIKit framework. And it is in pure Swift.
An UITreeView implementation from UITableView that Apple missed in its UIKit framework. And it is in pure Swift.
★★ Star our github repository to help us! ★★
Created by Partho Biswas (@ParthoBiswas007)
iOS 8.0+ / Swift 5.0+
This PBTreeView
has been drawn over UITableView
. Every row/node of the TreeView represents a UITableViewCell
with a custom object.
Step 1:
social_security_number
.Step 2:
TreeViewDataHandler
object and call it's following function passing the parsed data arraypublic func configureTreeViewDatasource(_ relationDetails: [RelationshipDetails]) -> [TreeViewNodeItem]?
And use the return value of the above function as TreeView's data source. Lile following.
var dataHandler: TreeViewDataHandler? = TreeViewDataHandler()
let relations: [RelationshipDetails]? = readJson(JSON_File_Name)
var treeViewDataSource = [TreeViewNodeItem]()
treeViewDataSource = (dataHandler?.configureTreeViewDatasource(relations!))!
Step 3:
RelodeTreeView
notification to relode the TreeView.NotificationCenter.default.addObserver(self, selector: #selector(relodeTreeView(_:)), name: NSNotification.Name(rawValue: "RelodeTreeView"), object: nil)
func relodeTreeView(_ notification: Notification) {
self.treeViewDataSource = (dataHandler?.refreshNodes())!
DispatchQueue.main.async {
self.famityTreeTableView.reloadData()
}
}
UITableViewCell
and UITableView
UITableViewCell
custom subclass for the TreeView node.Relations
and RelationshipDetails
object with your own with proper changes and requirments.Contributions are welcome. Please just open an Issue on GitHub to discuss a point or request a feature or send a Pull Request with your suggestion. If there's a related discussion on the Swift Evolution mailing list, please also post the thread name with a link.
Please also try to follow the same syntax and semantic in your commit messages (see rationale here).