CITreeView
CITreeView created to implement and maintain that wanted TreeView structures for IOS platforms easy way. CITreeView provides endless treeview structure. You just add your data to CITreeview datasource.
Installation
CocoaPods (Recommended)
- Add additional entry to your Podfile.
 
pod 'CITreeView', '~> 1.6.1'
- Pod Install
 
pod install
Manual
- Download .zip file
 - Just drag and drop CITreeViewClasses folder to your project
 
Usage
Initialization
- Firstly, import CITreeView
 
import CITreeView
- Add CITreeViewDelegate and CITreeViewDataSource to your view controller
 
class ViewController:UIViewController,CITreeViewDelegate,CITreeViewDataSource
- Initialize and configure CITreeView
 
let ciTreeView = CITreeView.init(frame: self.view.bounds, style: UITableViewStyle.plain)
ciTreeView.treeViewDelegate = self
ciTreeView.treeViewDataSource = self
self.view.addSubview(ciTreeView)
- Implement required methods of the CITreeView's delegates
 
func treeView(_ treeView: CITreeView, atIndexPath indexPath: IndexPath, withTreeViewNode treeViewNode: CITreeViewNode) -> UITableViewCell {
return cell;
}
func treeViewSelectedNodeChildren(for treeViewNodeItem: AnyObject) -> [AnyObject] {
        if let dataObj = treeViewNodeItem as? CITreeViewData {
            return dataObj.children
        }
        return []
    }
func treeViewDataArray() -> [AnyObject] {
return yourDataArray
}
func treeView(_ tableView: CITreeView, heightForRowAt indexPath: IndexPath, withTreeViewNode treeViewNode:CITreeViewNode) -> CGFloat {
return UITableViewAutomaticDimension
}
func treeView(_ treeView: CITreeView, didSelectRowAt treeViewNode:CITreeViewNode) {}
func willExpandTreeViewNode(treeViewNode: CITreeViewNode, atIndexPath: IndexPath) {}
func didExpandTreeViewNode(treeViewNode: CITreeViewNode, atIndexPath: IndexPath) {}
func willCollapseTreeViewNode(treeViewNode: CITreeViewNode, atIndexPath: IndexPath) {}
func didCollapseTreeViewNode(treeViewNode: CITreeViewNode, atIndexPath: IndexPath) {}
Features
- You can only open one node at a time if you wish. If another parent node is selected while a node is opened, the open nodes will closed automatically.
 
ciTreeView.collapseNoneSelectedRows = true
Recently Added Features
1. connect CITreeView delegate and datasource with interface builder
2. expand all rows with expandAllRows()
3. collapse all rows with collapseAllRows()
4. get parent node of selected node as CITreeViewNode.parentNode
5. reload data without lose rows states that expanded or collapses with reloadDataWithoutChangingRowStates()
License
MIT licensed, Copyright (c) 2018 Cenk Işık, @cekjacks

