• Stars
    star
    138
  • Rank 264,508 (Top 6 %)
  • Language
    Swift
  • Created over 7 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An UITreeView implementation from UITableView that Apple missed in its UIKit framework. And it is in pure Swift.

PBTreeView

Swift 5.0 iOS License Apache PerfectlySoft Twitter


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)

What's in it

  • An UITreeView implementation from UITableView.
  • An iOS application showing it's implementation and usage.

Preview

preview

Requirements

iOS 8.0+ / Swift 5.0+

Setup and Usage

This PBTreeView has been drawn over UITableView. Every row/node of the TreeView represents a UITableViewCell with a custom object.

Step 1:

  • First you need to arrange some datasource that seems like a tree. Check this JSON datasource as example.
  • This JSON data contains RelationshipDetails object as primary unit. This object will contain the information for each node of the tree. This object need to have an unique identifire. In this case, it's social_security_number.

Step 2:

  • Create a TreeViewDataHandler object and call it's following function passing the parsed data array
public 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:

  • Listen for 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()
    }
}

Customisation

Setting up UITableViewCell and UITableView

  • Create your own UITableViewCell custom subclass for the TreeView node.

Setting up custom data model

  • Just replace Relations and RelationshipDetails object with your own with proper changes and requirments.

Up Next

  • Dynamic addition and deletion of tree node.
  • Dyanmic Data Container
  • Dynamic View Holder

Contributing

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

More Repositories

1

coding-interview-gym

leetcode.com , algoexpert.io solutions in python and swift
Python
834
star
2

Java-Remote-Control

A remote logging software like TeamVIewer, entirely made with Java RMI, Swing.
Java
46
star
3

PBRecPlayer_Obj-C

An example of recording, encoding(G729), decoding and playing simultaniously through Audio Unit.
Objective-C
16
star
4

Perfect-Server-Side-Swift_iOS-App

A family tree API server implementation with iOS client. Server has been implemented with Perfect: Server-Side Swift And iOS client is in pure Swift.
15
star
5

PBRecPlayer_Swift

An example of recording, encoding(G729), decoding and playing simultaniously through Audio Unit. Uses swift.
Swift
14
star
6

Contacts-Combo_ObjC

It's a one stop solution for whatever you want to do with your iOS contacts. You can do anything and everything.
Objective-C
14
star
7

Backlog-Notes_Swift

Backlog notes shows the timeline view of things you want to do. Link: https://itunes.apple.com/us/app/backlog-notes/id850195712?mt=8
Swift
14
star
8

Backlog-Notes

Backlog notes shows the timeline view of things you want to do. Link: https://itunes.apple.com/us/app/backlog-notes/id850195712?mt=8
Objective-C
13
star
9

Task-Ticker_Obj-C

Source code for this app: https://itunes.apple.com/us/app/task-ticker-lite/id717509889?mt=8
Objective-C
12
star
10

AppShowcase

Showcases all of your iOS app into your apps and brings more downloads.
Objective-C
10
star
11

object-oriented-design-interview-gym

πŸ’Ž Object Oriented Design Patterns and Principles in Swift
Swift
9
star
12

Color-Tap_Corona-Game

A 2D game made by Corona SDK and Lua.
Lua
9
star
13

Propaganda-Postcards

A postcard maker app entilely made with Appcelerator Titanium
JavaScript
9
star
14

AppShowcase_Swift

Showcases all of your iOS app into your apps and brings more downloads.
Swift
7
star
15

Current-Weather

It fetches current weather informations from Open Weather Map API and display it nicely.
Objective-C
6
star
16

Crossover_Test

The test project for Software Architect (iOS/Swift) - $60k post at Crossover.
Swift
5
star
17

Perfect-Server-Side-Swift_Android-App

A family tree API server implementation with Android client. Server has been implemented with Perfect: Server-Side Swift And Android client is in pure Java.
4
star
18

Contacts-Combo_Swift

It's a one stop solution for whatever you want to do with your iOS contacts. You can do anything and everything.
3
star
19

TestAudio

C
1
star
20

Auto-SMS

Java
1
star