Swiftpack.co - Package - cenksk/CITreeView

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.

Twitter: @cekjacks CocoaPods Platform

|

Installation

CocoaPods (Recommended)

  1. Add additional entry to your Podfile.
pod 'CITreeView', '~> 1.6.1'
  1. Pod Install
pod install

Manual

  1. Download .zip file
  2. Just drag and drop CITreeViewClasses folder to your project

Usage

Initialization

  1. Firstly, import CITreeView
import CITreeView
  1. Add CITreeViewDelegate and CITreeViewDataSource to your view controller
class ViewController:UIViewController,CITreeViewDelegate,CITreeViewDataSource
  1. 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)
  1. 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

  1. 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

Github

link
Stars: 112

Dependencies

Used By

Total: 0

Releases

v1.6.1 - 2018-05-24 05:41:38

v1.0.6 - 2018-05-23 12:29:31

connect CITreeView delegate and datasource with interface builder get parent node of selected node as CITreeViewNode.parentNode reload data without lose rows states that expanded or collapses with reloadDataWithoutChangingRowStates()

v1.4.0 - 2018-03-25 19:12:00

Expand All Rows Collapse All Rows Remember the last state of tree view when reloading data

v.1.3.0 - 2018-03-11 21:20:59

v1.2.0 - 2018-03-11 21:02:44

v1.1.0 - 2018-01-31 20:04:06

Optimazing collapse animation Changing expected data type

1.0.0 for pod - 2018-01-28 18:11:00

Release for Pod