代码介绍地址:介绍地址
iOS | tvOS
:-------------------------:|:-------------------------:
RATreeView 是一个类,旨在提供简单愉快的方式在 iOS 和 tvOS 上使用树视图。 它作为 UITableView 的包装器,定义自己的委托和数据源方法,使得使用树数据结构变得非常容易。
RATreeView 是高度可定制的,并有很多功能。
CocoaPods is the recommended way to add RATreeView to your project.
pod "RATreeView", "~> 2.1.1"
pod install
command.#import <RATreeView.h>
.###Source files
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 control
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];
RATreeView was created by Rafał Augustyniak. You can find me on twitter (@RaAugustyniak).
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.