👷 Project created and maintained by Rafał Augustyniak. You can find me on twitter (@RaAugustyniak).
iOS | tvOS |
---|---|
RATreeView is a class designed to provide easy and pleasant way to work with tree views on iOS and tvOS. It works as a wrapper for the UITableView, defining its own delegate and data source methods which make working with tree data structures really easy.
RATreeView is highly customizable and has a lot of features.
CocoaPods is the recommended way to add RATreeView to your project.
Add additional entry to your Podfile.
pod "RATreeView", "~> 2.1.2"
Install Pod(s) running pod install
command.
Include RATreeView using #import <RATreeView.h>
.
Check out the demo for example usage of library. Make sure you read the RATreeView documentation on Cocoa Docs.
Add following import in file of your project when you want to use RATreeView:
// In case you are using RATreeView with CocoaPods
#import <RATreeView.h>
// In case you are using RATreeView by simply copying
// source files of the RATreeView into your project
#import "RATreeView.h"
Simplest way to initialize and configure RATreeView:
RATreeView *treeView = [[RATreeView alloc] initWithFrame:self.view.bounds];
treeView.delegate = self;
treeView.dataSource = self;
[self.view addSubview:treeView];
[treeView reloadData];
Implement required methods of the RATreeView's data source:
- (NSInteger)treeView:(RATreeView *)treeView numberOfChildrenOfItem:(id)item
{
return item ? 3 : 0;
}
- (UITableViewCell *)treeView:(RATreeView *)treeView cellForItem:(id)item treeNodeInfo:(RATreeNodeInfo *)treeNodeInfo
{
// create and configure cell for *item*
return cell
}
- (id)treeView:(RATreeView *)treeView child:(NSInteger)index ofItem:(id)item
{
return @(index);
}
Adding pull to refresh gesture is really easy using RATreeView
and standard UIRefreshControl
control.
UIRefreshControl *refreshControl = [UIRefreshControl new];
[refreshControl addTarget:self action:@selector(refreshControlChanged:) forControlEvents:UIControlEventValueChanged];
[treeView.scrollView addSubview:refreshControl];
Documentation is available on CocoaPods.
RATreeView was created by Rafał Augustyniak. You can find me on twitter (@RaAugustyniak).
Information about newer versions of the library can be found in the releases section of the repository.
Version 1.0.2
Version 1.0.1
Version 1.0.0
expandRowForItem: expandChildren:withRowAnimation:
method. Default behavior is non recursive expand.collapseRowForItem: expandChildren:withRowAnimation:
method. Default behavior is non recursive collapse.itemForRowAtPoint:
method when passed point isn't inside any cell.Version 0.9.2
endUpdates
method.Version 0.9.1
Version 0.9.0
RATreeNodeInfo
class.RATreeNodeInfo
class.MIT licensed, Copyright (c) 2014 Rafał Augustyniak, @RaAugustyniak