├── BDDynamicTree.xcworkspace
├── contents.xcworkspacedata
└── xcuserdata
│ └── gaoruiqiang.xcuserdatad
│ └── UserInterfaceState.xcuserstate
├── BDDynamicTree
├── BDDynamicTree.h
├── BDDynamicTree.m
├── BDDynamicTreeCell.h
├── BDDynamicTreeCell.m
├── BDDynamicTreeCell.xib
├── BDDynamicTreeNode.h
└── BDDynamicTreeNode.m
├── BDDynamicTreeDemo
├── BDDynamicTreeDemo.xcodeproj
│ ├── project.pbxproj
│ └── xcuserdata
│ │ └── gaoruiqiang.xcuserdatad
│ │ └── xcschemes
│ │ ├── BDDynamicTreeDemo.xcscheme
│ │ └── xcschememanagement.plist
├── BDDynamicTreeDemo
│ ├── BDAppDelegate.h
│ ├── BDAppDelegate.m
│ ├── BDDynamicTreeDemo-Info.plist
│ ├── BDDynamicTreeDemo-Prefix.pch
│ ├── BDViewController.h
│ ├── BDViewController.m
│ ├── Base.lproj
│ │ ├── Main_iPad.storyboard
│ │ └── Main_iPhone.storyboard
│ ├── Images.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── LaunchImage.launchimage
│ │ │ └── Contents.json
│ ├── Resources
│ │ ├── 2.jpg
│ │ ├── icon_minus@2x.png
│ │ └── icon_plus@2x.png
│ ├── en.lproj
│ │ └── InfoPlist.strings
│ └── main.m
└── BDDynamicTreeDemoTests
│ ├── BDDynamicTreeDemoTests-Info.plist
│ ├── BDDynamicTreeDemoTests.m
│ └── en.lproj
│ └── InfoPlist.strings
└── README.md
/BDDynamicTree.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/BDDynamicTree.xcworkspace/xcuserdata/gaoruiqiang.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reference/BDDynamicTree/1f0e3c8cf5e1931aef3fbef352bfc1d3f0f72c6f/BDDynamicTree.xcworkspace/xcuserdata/gaoruiqiang.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/BDDynamicTree/BDDynamicTree.h:
--------------------------------------------------------------------------------
1 | //
2 | // BDDynamicTree.h
3 | //
4 | // Created by Scott Ban (https://github.com/reference) on 14/07/30.
5 | // Copyright (C) 2011-2020 by Scott Ban
6 |
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #import
26 |
27 | @class BDDynamicTree;
28 | @class BDDynamicTreeNode;
29 |
30 | @protocol BDDynamicTreeDelegate
31 | @optional
32 | - (void)dynamicTree:(BDDynamicTree *)dynamicTree didSelectedRowWithNode:(BDDynamicTreeNode *)node;
33 | @end
34 |
35 | @interface BDDynamicTree : UIView
36 | @property (nonatomic,assign) id delegate;
37 |
38 | /*!
39 | *@method initWithFrame:nodes:
40 | *@abstract 初始化
41 | *@param frame 坐标大小
42 | *@param nodes `BDDynamicTreeNode`数组
43 | *@return 当前对象
44 | */
45 | - (id)initWithFrame:(CGRect)frame nodes:(NSArray *)nodes;
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/BDDynamicTree/BDDynamicTree.m:
--------------------------------------------------------------------------------
1 | //
2 | // BDDynamicTree.m
3 | //
4 | // Created by Scott Ban (https://github.com/reference) on 14/07/30.
5 | // Copyright (C) 2011-2020 by Scott Ban
6 |
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #import "BDDynamicTree.h"
26 | #import "BDDynamicTreeNode.h"
27 | #import "BDDynamicTreeCell.h"
28 |
29 | @interface BDDynamicTree ()
30 | {
31 | UITableView *_tableView;
32 | NSMutableArray *_dataSource;
33 | NSMutableArray *_nodesArray;
34 | }
35 | @end
36 |
37 | @implementation BDDynamicTree
38 |
39 | - (id)initWithFrame:(CGRect)frame nodes:(NSArray *)nodes
40 | {
41 | self = [super initWithFrame:frame];
42 | if (self) {
43 |
44 | _dataSource = [[NSMutableArray alloc] init];
45 | _nodesArray = [[NSMutableArray alloc] init];
46 |
47 | if (nodes && nodes.count) {
48 | [_nodesArray addObjectsFromArray:nodes];
49 |
50 | //添加根节点
51 | [_dataSource addObject:[self rootNode]];
52 | }
53 |
54 | //tableview
55 | _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)
56 | style:UITableViewStylePlain];
57 | _tableView.delegate = self;
58 | _tableView.dataSource = self;
59 | _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
60 | [self addSubview:_tableView];
61 | }
62 | return self;
63 | }
64 |
65 | #pragma mark - private methods
66 |
67 | - (BDDynamicTreeNode *)rootNode
68 | {
69 | for (BDDynamicTreeNode *node in _nodesArray) {
70 | if ([node isRoot]) {
71 | return node;
72 | }
73 | }
74 | return nil;
75 | }
76 |
77 | //添加子节点
78 | - (void)addSubNodesByFatherNode:(BDDynamicTreeNode *)fatherNode atIndex:(NSInteger )index
79 | {
80 | if (fatherNode)
81 | {
82 | NSMutableArray *array = [NSMutableArray array];
83 | NSMutableArray *cellIndexPaths = [NSMutableArray array];
84 |
85 | NSUInteger count = index;
86 | for(BDDynamicTreeNode *node in _nodesArray) {
87 | if ([node.fatherNodeId isEqualToString:fatherNode.nodeId]) {
88 | node.originX = fatherNode.originX + 10/*space*/;
89 | [array addObject:node];
90 | [cellIndexPaths addObject:[NSIndexPath indexPathForRow:count++ inSection:0]];
91 | }
92 | }
93 |
94 | if (array.count) {
95 | fatherNode.isOpen = YES;
96 | fatherNode.subNodes = array;
97 |
98 | NSIndexSet *indexes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(index,[array count])];
99 | [_dataSource insertObjects:array atIndexes:indexes];
100 | [_tableView insertRowsAtIndexPaths:cellIndexPaths withRowAnimation:UITableViewRowAnimationFade];
101 | [_tableView reloadData];
102 | }
103 | }
104 | }
105 |
106 | //根据节点减去子节点
107 | - (void)minusNodesByNode:(BDDynamicTreeNode *)node
108 | {
109 | if (node) {
110 |
111 | NSMutableArray *nodes = [NSMutableArray arrayWithArray:_dataSource];
112 | for (BDDynamicTreeNode *nd in nodes) {
113 | if ([nd.fatherNodeId isEqualToString:node.nodeId]) {
114 | [_dataSource removeObject:nd];
115 | [self minusNodesByNode:nd];
116 | }
117 | }
118 |
119 | node.isOpen = NO;
120 | [_tableView reloadData];
121 | }
122 | }
123 |
124 | #pragma mark - UITableViewDelegate & UITableViewDataSource
125 |
126 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
127 | {
128 | return _dataSource.count;
129 | }
130 |
131 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
132 | {
133 | BDDynamicTreeNode *node = _dataSource[indexPath.row];
134 | CellType type = node.isDepartment?CellType_Department:CellType_Employee;
135 | return [BDDynamicTreeCell heightForCellWithType:type];
136 | }
137 |
138 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
139 | {
140 | static NSString *CellIdentifier = @"Cell";
141 |
142 | BDDynamicTreeCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
143 | if (cell == nil) {
144 | NSArray* topObjects = [[NSBundle mainBundle] loadNibNamed:@"BDDynamicTreeCell" owner:self options:nil];
145 | cell = [topObjects objectAtIndex:0];
146 | }
147 |
148 | [cell fillWithNode:_dataSource[indexPath.row]];
149 | return cell;
150 | }
151 |
152 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
153 | {
154 | [tableView deselectRowAtIndexPath:indexPath animated:YES];
155 |
156 | BDDynamicTreeNode *node = _dataSource[indexPath.row];
157 |
158 | //callback
159 | if (self.delegate && [self.delegate respondsToSelector:@selector(dynamicTree:didSelectedRowWithNode:)]) {
160 | [self.delegate dynamicTree:self didSelectedRowWithNode:node];
161 | }
162 |
163 | if (node.isDepartment) {
164 | if (node.isOpen) {
165 | //减
166 | [self minusNodesByNode:node];
167 | }
168 | else{
169 | //加一个
170 | NSUInteger index=indexPath.row+1;
171 |
172 | [self addSubNodesByFatherNode:node atIndex:index];
173 | }
174 | }
175 | }
176 |
177 | @end
178 |
--------------------------------------------------------------------------------
/BDDynamicTree/BDDynamicTreeCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // BDDynamicTreeCell.h
3 | //
4 | // Created by Scott Ban (https://github.com/reference) on 14/07/30.
5 | // Copyright (C) 2011-2020 by Scott Ban
6 |
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #import
26 | #import "BDDynamicTreeNode.h"
27 |
28 | typedef enum {
29 | CellType_Department = 1, //目录
30 | CellType_Employee //雇员
31 | }CellType;
32 |
33 | @interface BDDynamicTreeCell : UITableViewCell
34 | @property (nonatomic, strong) IBOutlet UIImageView *avatarImageView;
35 | @property (nonatomic, strong) IBOutlet UIImageView *plusImageView;
36 | @property (nonatomic, strong) IBOutlet UILabel *labelTitle;
37 | @property (nonatomic, strong) IBOutlet UIView *underLine;
38 |
39 | + (CGFloat)heightForCellWithType:(CellType)type;
40 |
41 | - (void)fillWithNode:(BDDynamicTreeNode*)node;
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/BDDynamicTree/BDDynamicTreeCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // BDDynamicTreeCell.m
3 | //
4 | // Created by Scott Ban (https://github.com/reference) on 14/07/30.
5 | // Copyright (C) 2011-2020 by Scott Ban
6 |
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #import "BDDynamicTreeCell.h"
26 |
27 | #define DepartmentCellHeight 44
28 | #define EmployeeCellHeight 60
29 |
30 | @interface BDDynamicTreeCell ()
31 | @end
32 |
33 | @implementation BDDynamicTreeCell
34 |
35 | - (void)awakeFromNib
36 | {
37 | [super awakeFromNib];
38 |
39 | self.avatarImageView.layer.cornerRadius = 5.f;
40 | self.avatarImageView.layer.masksToBounds = YES;
41 | }
42 |
43 | + (CGFloat)heightForCellWithType:(CellType)type
44 | {
45 | if (type == CellType_Department) {
46 | return DepartmentCellHeight;
47 | }
48 | return EmployeeCellHeight;
49 | }
50 |
51 | - (void)fillWithNode:(BDDynamicTreeNode*)node
52 | {
53 | if (node) {
54 | NSInteger cellType = node.isDepartment;
55 |
56 | [self setCellStypeWithType:cellType originX:node.originX];
57 |
58 | if (cellType == CellType_Department) {
59 | if ([node isRoot]) {
60 | self.labelTitle.text = [NSString stringWithFormat:@"%@",node.name];
61 | }else{
62 | self.labelTitle.text = [NSString stringWithFormat:@"%@(%lu)",node.name,(unsigned long)node.subNodes.count];
63 | }
64 |
65 | if (node.isOpen) {
66 | self.plusImageView.image = [UIImage imageNamed:@"icon_minus"];
67 | }
68 | }
69 | else{
70 | NSDictionary *dic = node.data;
71 | self.labelTitle.text = dic[@"name"];
72 |
73 | self.avatarImageView.image = [UIImage imageNamed:@"2.jpg"];
74 | }
75 | }
76 | }
77 |
78 | - (void)setCellStypeWithType:(NSInteger)type originX:(CGFloat)x
79 | {
80 | if (type == CellType_Department) {
81 | self.contentView.frame = CGRectMake(self.contentView.frame.origin.x,
82 | self.contentView.frame.origin.y,
83 | self.contentView.frame.size.width, DepartmentCellHeight);
84 |
85 | self.avatarImageView.hidden = YES;
86 |
87 | //设置 + 号的位置
88 | self.plusImageView.frame = CGRectMake(x, self.plusImageView.frame.origin.y,
89 | self.plusImageView.frame.size.width,
90 | self.plusImageView.frame.size.height);
91 |
92 | //设置 label的位置
93 | self.labelTitle.frame = CGRectMake(self.plusImageView.frame.origin.x+self.plusImageView.frame.size.width + 5/*space*/, 0,
94 | self.contentView.frame.size.width - self.plusImageView.frame.origin.x - self.plusImageView.frame.size.width - 5 - 5/*space*/,
95 | self.contentView.frame.size.height);
96 |
97 | //underline
98 | self.underLine.frame = CGRectMake(x,
99 | self.contentView.frame.size.height - 0.5,
100 | self.contentView.frame.size.width - x,
101 | 0.5);
102 | self.underLine.backgroundColor = [UIColor colorWithRed:242/255.f green:244/255.f blue:246/255.f alpha:1];
103 |
104 | }
105 | else{
106 | self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
107 |
108 | self.contentView.frame = CGRectMake(self.contentView.frame.origin.x,
109 | self.contentView.frame.origin.y,
110 | self.contentView.frame.size.width, EmployeeCellHeight);
111 |
112 | self.plusImageView.hidden = YES;
113 |
114 | //设置头像的位置
115 | CGFloat iconWidth = EmployeeCellHeight - 10;
116 | self.avatarImageView.frame = CGRectMake(x, EmployeeCellHeight/2.f - iconWidth/2.f, iconWidth, iconWidth);
117 |
118 | //这是label
119 | self.labelTitle.frame = CGRectMake(self.avatarImageView.frame.origin.x+self.avatarImageView.frame.size.width + 5/*space*/,
120 | 0,
121 | self.contentView.frame.size.width - self.avatarImageView.frame.origin.x - self.avatarImageView.frame.size.width - 5 - 5/*space*/,
122 | self.contentView.frame.size.height);
123 |
124 | //underline
125 | self.underLine.frame = CGRectMake(x,
126 | self.contentView.frame.size.height - 0.5,
127 | self.contentView.frame.size.width - x,
128 | 0.5);
129 | self.underLine.backgroundColor = [UIColor colorWithRed:242/255.f green:244/255.f blue:246/255.f alpha:1];
130 | }
131 | }
132 |
133 | @end
134 |
--------------------------------------------------------------------------------
/BDDynamicTree/BDDynamicTreeCell.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/BDDynamicTree/BDDynamicTreeNode.h:
--------------------------------------------------------------------------------
1 | //
2 | // BDDynamicTreeNode.h
3 | //
4 | // Created by Scott Ban (https://github.com/reference) on 14/07/30.
5 | // Copyright (C) 2011-2020 by Scott Ban
6 |
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #import
26 |
27 | @interface BDDynamicTreeNode : NSObject
28 |
29 | @property (nonatomic, assign) CGFloat originX; //坐标x
30 | @property (nonatomic, strong) NSString *name; //名称
31 | @property (nonatomic, strong) NSDictionary *data; //节点详细
32 | @property (nonatomic, strong) NSArray *subNodes; //子节点
33 | @property (nonatomic, strong) NSString *fatherNodeId; //父节点的id
34 | @property (nonatomic, strong) NSString *nodeId; //当前节点id
35 | @property (nonatomic, assign) BOOL isDepartment; //是否是部门
36 | @property (nonatomic, assign) BOOL isOpen; //是否展开的
37 |
38 | //检查是否根节点
39 | - (BOOL)isRoot;
40 |
41 | @end
42 |
--------------------------------------------------------------------------------
/BDDynamicTree/BDDynamicTreeNode.m:
--------------------------------------------------------------------------------
1 | //
2 | // BDDynamicTreeNode.m
3 | //
4 | // Created by Scott Ban (https://github.com/reference) on 14/07/30.
5 | // Copyright (C) 2011-2020 by Scott Ban
6 |
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #import "BDDynamicTreeNode.h"
26 |
27 | @implementation BDDynamicTreeNode
28 |
29 | - (BOOL)isRoot
30 | {
31 | return self.fatherNodeId == nil;
32 | }
33 |
34 | - (NSString *)description
35 | {
36 | return [NSString stringWithFormat:@"name:%@",self.name];
37 | }
38 |
39 | @end
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 1AFB1F29198B9E5B0097C28B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AFB1F28198B9E5B0097C28B /* Foundation.framework */; };
11 | 1AFB1F2B198B9E5B0097C28B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AFB1F2A198B9E5B0097C28B /* CoreGraphics.framework */; };
12 | 1AFB1F2D198B9E5B0097C28B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AFB1F2C198B9E5B0097C28B /* UIKit.framework */; };
13 | 1AFB1F33198B9E5B0097C28B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1AFB1F31198B9E5B0097C28B /* InfoPlist.strings */; };
14 | 1AFB1F35198B9E5B0097C28B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AFB1F34198B9E5B0097C28B /* main.m */; };
15 | 1AFB1F39198B9E5B0097C28B /* BDAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AFB1F38198B9E5B0097C28B /* BDAppDelegate.m */; };
16 | 1AFB1F3C198B9E5B0097C28B /* Main_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1AFB1F3A198B9E5B0097C28B /* Main_iPhone.storyboard */; };
17 | 1AFB1F3F198B9E5B0097C28B /* Main_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1AFB1F3D198B9E5B0097C28B /* Main_iPad.storyboard */; };
18 | 1AFB1F42198B9E5B0097C28B /* BDViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AFB1F41198B9E5B0097C28B /* BDViewController.m */; };
19 | 1AFB1F44198B9E5B0097C28B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1AFB1F43198B9E5B0097C28B /* Images.xcassets */; };
20 | 1AFB1F4B198B9E5B0097C28B /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AFB1F4A198B9E5B0097C28B /* XCTest.framework */; };
21 | 1AFB1F4C198B9E5B0097C28B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AFB1F28198B9E5B0097C28B /* Foundation.framework */; };
22 | 1AFB1F4D198B9E5B0097C28B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AFB1F2C198B9E5B0097C28B /* UIKit.framework */; };
23 | 1AFB1F55198B9E5B0097C28B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1AFB1F53198B9E5B0097C28B /* InfoPlist.strings */; };
24 | 1AFB1F57198B9E5B0097C28B /* BDDynamicTreeDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AFB1F56198B9E5B0097C28B /* BDDynamicTreeDemoTests.m */; };
25 | 1AFB1F68198B9EC70097C28B /* BDDynamicTree.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AFB1F62198B9EC70097C28B /* BDDynamicTree.m */; };
26 | 1AFB1F69198B9EC70097C28B /* BDDynamicTreeCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AFB1F64198B9EC70097C28B /* BDDynamicTreeCell.m */; };
27 | 1AFB1F6A198B9EC70097C28B /* BDDynamicTreeCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1AFB1F65198B9EC70097C28B /* BDDynamicTreeCell.xib */; };
28 | 1AFB1F6B198B9EC70097C28B /* BDDynamicTreeNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AFB1F67198B9EC70097C28B /* BDDynamicTreeNode.m */; };
29 | 1AFB1F70198B9F050097C28B /* 2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 1AFB1F6D198B9F050097C28B /* 2.jpg */; };
30 | 1AFB1F71198B9F050097C28B /* icon_minus@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AFB1F6E198B9F050097C28B /* icon_minus@2x.png */; };
31 | 1AFB1F72198B9F050097C28B /* icon_plus@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AFB1F6F198B9F050097C28B /* icon_plus@2x.png */; };
32 | /* End PBXBuildFile section */
33 |
34 | /* Begin PBXContainerItemProxy section */
35 | 1AFB1F4E198B9E5B0097C28B /* PBXContainerItemProxy */ = {
36 | isa = PBXContainerItemProxy;
37 | containerPortal = 1AFB1F1D198B9E5B0097C28B /* Project object */;
38 | proxyType = 1;
39 | remoteGlobalIDString = 1AFB1F24198B9E5B0097C28B;
40 | remoteInfo = BDDynamicTreeDemo;
41 | };
42 | /* End PBXContainerItemProxy section */
43 |
44 | /* Begin PBXFileReference section */
45 | 1AFB1F25198B9E5B0097C28B /* BDDynamicTreeDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BDDynamicTreeDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
46 | 1AFB1F28198B9E5B0097C28B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
47 | 1AFB1F2A198B9E5B0097C28B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
48 | 1AFB1F2C198B9E5B0097C28B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
49 | 1AFB1F30198B9E5B0097C28B /* BDDynamicTreeDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "BDDynamicTreeDemo-Info.plist"; sourceTree = ""; };
50 | 1AFB1F32198B9E5B0097C28B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
51 | 1AFB1F34198B9E5B0097C28B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
52 | 1AFB1F36198B9E5B0097C28B /* BDDynamicTreeDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BDDynamicTreeDemo-Prefix.pch"; sourceTree = ""; };
53 | 1AFB1F37198B9E5B0097C28B /* BDAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BDAppDelegate.h; sourceTree = ""; };
54 | 1AFB1F38198B9E5B0097C28B /* BDAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BDAppDelegate.m; sourceTree = ""; };
55 | 1AFB1F3B198B9E5B0097C28B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main_iPhone.storyboard; sourceTree = ""; };
56 | 1AFB1F3E198B9E5B0097C28B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main_iPad.storyboard; sourceTree = ""; };
57 | 1AFB1F40198B9E5B0097C28B /* BDViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BDViewController.h; sourceTree = ""; };
58 | 1AFB1F41198B9E5B0097C28B /* BDViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BDViewController.m; sourceTree = ""; };
59 | 1AFB1F43198B9E5B0097C28B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
60 | 1AFB1F49198B9E5B0097C28B /* BDDynamicTreeDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BDDynamicTreeDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
61 | 1AFB1F4A198B9E5B0097C28B /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
62 | 1AFB1F52198B9E5B0097C28B /* BDDynamicTreeDemoTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "BDDynamicTreeDemoTests-Info.plist"; sourceTree = ""; };
63 | 1AFB1F54198B9E5B0097C28B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
64 | 1AFB1F56198B9E5B0097C28B /* BDDynamicTreeDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BDDynamicTreeDemoTests.m; sourceTree = ""; };
65 | 1AFB1F61198B9EC70097C28B /* BDDynamicTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDDynamicTree.h; sourceTree = ""; };
66 | 1AFB1F62198B9EC70097C28B /* BDDynamicTree.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BDDynamicTree.m; sourceTree = ""; };
67 | 1AFB1F63198B9EC70097C28B /* BDDynamicTreeCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDDynamicTreeCell.h; sourceTree = ""; };
68 | 1AFB1F64198B9EC70097C28B /* BDDynamicTreeCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BDDynamicTreeCell.m; sourceTree = ""; };
69 | 1AFB1F65198B9EC70097C28B /* BDDynamicTreeCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BDDynamicTreeCell.xib; sourceTree = ""; };
70 | 1AFB1F66198B9EC70097C28B /* BDDynamicTreeNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDDynamicTreeNode.h; sourceTree = ""; };
71 | 1AFB1F67198B9EC70097C28B /* BDDynamicTreeNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BDDynamicTreeNode.m; sourceTree = ""; };
72 | 1AFB1F6D198B9F050097C28B /* 2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 2.jpg; sourceTree = ""; };
73 | 1AFB1F6E198B9F050097C28B /* icon_minus@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_minus@2x.png"; sourceTree = ""; };
74 | 1AFB1F6F198B9F050097C28B /* icon_plus@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_plus@2x.png"; sourceTree = ""; };
75 | /* End PBXFileReference section */
76 |
77 | /* Begin PBXFrameworksBuildPhase section */
78 | 1AFB1F22198B9E5B0097C28B /* Frameworks */ = {
79 | isa = PBXFrameworksBuildPhase;
80 | buildActionMask = 2147483647;
81 | files = (
82 | 1AFB1F2B198B9E5B0097C28B /* CoreGraphics.framework in Frameworks */,
83 | 1AFB1F2D198B9E5B0097C28B /* UIKit.framework in Frameworks */,
84 | 1AFB1F29198B9E5B0097C28B /* Foundation.framework in Frameworks */,
85 | );
86 | runOnlyForDeploymentPostprocessing = 0;
87 | };
88 | 1AFB1F46198B9E5B0097C28B /* Frameworks */ = {
89 | isa = PBXFrameworksBuildPhase;
90 | buildActionMask = 2147483647;
91 | files = (
92 | 1AFB1F4B198B9E5B0097C28B /* XCTest.framework in Frameworks */,
93 | 1AFB1F4D198B9E5B0097C28B /* UIKit.framework in Frameworks */,
94 | 1AFB1F4C198B9E5B0097C28B /* Foundation.framework in Frameworks */,
95 | );
96 | runOnlyForDeploymentPostprocessing = 0;
97 | };
98 | /* End PBXFrameworksBuildPhase section */
99 |
100 | /* Begin PBXGroup section */
101 | 1AFB1F1C198B9E5B0097C28B = {
102 | isa = PBXGroup;
103 | children = (
104 | 1AFB1F2E198B9E5B0097C28B /* BDDynamicTreeDemo */,
105 | 1AFB1F50198B9E5B0097C28B /* BDDynamicTreeDemoTests */,
106 | 1AFB1F27198B9E5B0097C28B /* Frameworks */,
107 | 1AFB1F26198B9E5B0097C28B /* Products */,
108 | );
109 | sourceTree = "";
110 | };
111 | 1AFB1F26198B9E5B0097C28B /* Products */ = {
112 | isa = PBXGroup;
113 | children = (
114 | 1AFB1F25198B9E5B0097C28B /* BDDynamicTreeDemo.app */,
115 | 1AFB1F49198B9E5B0097C28B /* BDDynamicTreeDemoTests.xctest */,
116 | );
117 | name = Products;
118 | sourceTree = "";
119 | };
120 | 1AFB1F27198B9E5B0097C28B /* Frameworks */ = {
121 | isa = PBXGroup;
122 | children = (
123 | 1AFB1F28198B9E5B0097C28B /* Foundation.framework */,
124 | 1AFB1F2A198B9E5B0097C28B /* CoreGraphics.framework */,
125 | 1AFB1F2C198B9E5B0097C28B /* UIKit.framework */,
126 | 1AFB1F4A198B9E5B0097C28B /* XCTest.framework */,
127 | );
128 | name = Frameworks;
129 | sourceTree = "";
130 | };
131 | 1AFB1F2E198B9E5B0097C28B /* BDDynamicTreeDemo */ = {
132 | isa = PBXGroup;
133 | children = (
134 | 1AFB1F60198B9EC70097C28B /* BDDynamicTree */,
135 | 1AFB1F37198B9E5B0097C28B /* BDAppDelegate.h */,
136 | 1AFB1F38198B9E5B0097C28B /* BDAppDelegate.m */,
137 | 1AFB1F3A198B9E5B0097C28B /* Main_iPhone.storyboard */,
138 | 1AFB1F3D198B9E5B0097C28B /* Main_iPad.storyboard */,
139 | 1AFB1F40198B9E5B0097C28B /* BDViewController.h */,
140 | 1AFB1F41198B9E5B0097C28B /* BDViewController.m */,
141 | 1AFB1F43198B9E5B0097C28B /* Images.xcassets */,
142 | 1AFB1F6C198B9F050097C28B /* Resources */,
143 | 1AFB1F2F198B9E5B0097C28B /* Supporting Files */,
144 | );
145 | path = BDDynamicTreeDemo;
146 | sourceTree = "";
147 | };
148 | 1AFB1F2F198B9E5B0097C28B /* Supporting Files */ = {
149 | isa = PBXGroup;
150 | children = (
151 | 1AFB1F30198B9E5B0097C28B /* BDDynamicTreeDemo-Info.plist */,
152 | 1AFB1F31198B9E5B0097C28B /* InfoPlist.strings */,
153 | 1AFB1F34198B9E5B0097C28B /* main.m */,
154 | 1AFB1F36198B9E5B0097C28B /* BDDynamicTreeDemo-Prefix.pch */,
155 | );
156 | name = "Supporting Files";
157 | sourceTree = "";
158 | };
159 | 1AFB1F50198B9E5B0097C28B /* BDDynamicTreeDemoTests */ = {
160 | isa = PBXGroup;
161 | children = (
162 | 1AFB1F56198B9E5B0097C28B /* BDDynamicTreeDemoTests.m */,
163 | 1AFB1F51198B9E5B0097C28B /* Supporting Files */,
164 | );
165 | path = BDDynamicTreeDemoTests;
166 | sourceTree = "";
167 | };
168 | 1AFB1F51198B9E5B0097C28B /* Supporting Files */ = {
169 | isa = PBXGroup;
170 | children = (
171 | 1AFB1F52198B9E5B0097C28B /* BDDynamicTreeDemoTests-Info.plist */,
172 | 1AFB1F53198B9E5B0097C28B /* InfoPlist.strings */,
173 | );
174 | name = "Supporting Files";
175 | sourceTree = "";
176 | };
177 | 1AFB1F60198B9EC70097C28B /* BDDynamicTree */ = {
178 | isa = PBXGroup;
179 | children = (
180 | 1AFB1F61198B9EC70097C28B /* BDDynamicTree.h */,
181 | 1AFB1F62198B9EC70097C28B /* BDDynamicTree.m */,
182 | 1AFB1F66198B9EC70097C28B /* BDDynamicTreeNode.h */,
183 | 1AFB1F67198B9EC70097C28B /* BDDynamicTreeNode.m */,
184 | 1AFB1F63198B9EC70097C28B /* BDDynamicTreeCell.h */,
185 | 1AFB1F64198B9EC70097C28B /* BDDynamicTreeCell.m */,
186 | 1AFB1F65198B9EC70097C28B /* BDDynamicTreeCell.xib */,
187 | );
188 | name = BDDynamicTree;
189 | path = ../../BDDynamicTree;
190 | sourceTree = "";
191 | };
192 | 1AFB1F6C198B9F050097C28B /* Resources */ = {
193 | isa = PBXGroup;
194 | children = (
195 | 1AFB1F6D198B9F050097C28B /* 2.jpg */,
196 | 1AFB1F6E198B9F050097C28B /* icon_minus@2x.png */,
197 | 1AFB1F6F198B9F050097C28B /* icon_plus@2x.png */,
198 | );
199 | path = Resources;
200 | sourceTree = "";
201 | };
202 | /* End PBXGroup section */
203 |
204 | /* Begin PBXNativeTarget section */
205 | 1AFB1F24198B9E5B0097C28B /* BDDynamicTreeDemo */ = {
206 | isa = PBXNativeTarget;
207 | buildConfigurationList = 1AFB1F5A198B9E5B0097C28B /* Build configuration list for PBXNativeTarget "BDDynamicTreeDemo" */;
208 | buildPhases = (
209 | 1AFB1F21198B9E5B0097C28B /* Sources */,
210 | 1AFB1F22198B9E5B0097C28B /* Frameworks */,
211 | 1AFB1F23198B9E5B0097C28B /* Resources */,
212 | );
213 | buildRules = (
214 | );
215 | dependencies = (
216 | );
217 | name = BDDynamicTreeDemo;
218 | productName = BDDynamicTreeDemo;
219 | productReference = 1AFB1F25198B9E5B0097C28B /* BDDynamicTreeDemo.app */;
220 | productType = "com.apple.product-type.application";
221 | };
222 | 1AFB1F48198B9E5B0097C28B /* BDDynamicTreeDemoTests */ = {
223 | isa = PBXNativeTarget;
224 | buildConfigurationList = 1AFB1F5D198B9E5B0097C28B /* Build configuration list for PBXNativeTarget "BDDynamicTreeDemoTests" */;
225 | buildPhases = (
226 | 1AFB1F45198B9E5B0097C28B /* Sources */,
227 | 1AFB1F46198B9E5B0097C28B /* Frameworks */,
228 | 1AFB1F47198B9E5B0097C28B /* Resources */,
229 | );
230 | buildRules = (
231 | );
232 | dependencies = (
233 | 1AFB1F4F198B9E5B0097C28B /* PBXTargetDependency */,
234 | );
235 | name = BDDynamicTreeDemoTests;
236 | productName = BDDynamicTreeDemoTests;
237 | productReference = 1AFB1F49198B9E5B0097C28B /* BDDynamicTreeDemoTests.xctest */;
238 | productType = "com.apple.product-type.bundle.unit-test";
239 | };
240 | /* End PBXNativeTarget section */
241 |
242 | /* Begin PBXProject section */
243 | 1AFB1F1D198B9E5B0097C28B /* Project object */ = {
244 | isa = PBXProject;
245 | attributes = {
246 | CLASSPREFIX = BD;
247 | LastUpgradeCheck = 0510;
248 | ORGANIZATIONNAME = "Scott Ban";
249 | TargetAttributes = {
250 | 1AFB1F48198B9E5B0097C28B = {
251 | TestTargetID = 1AFB1F24198B9E5B0097C28B;
252 | };
253 | };
254 | };
255 | buildConfigurationList = 1AFB1F20198B9E5B0097C28B /* Build configuration list for PBXProject "BDDynamicTreeDemo" */;
256 | compatibilityVersion = "Xcode 3.2";
257 | developmentRegion = English;
258 | hasScannedForEncodings = 0;
259 | knownRegions = (
260 | en,
261 | Base,
262 | );
263 | mainGroup = 1AFB1F1C198B9E5B0097C28B;
264 | productRefGroup = 1AFB1F26198B9E5B0097C28B /* Products */;
265 | projectDirPath = "";
266 | projectRoot = "";
267 | targets = (
268 | 1AFB1F24198B9E5B0097C28B /* BDDynamicTreeDemo */,
269 | 1AFB1F48198B9E5B0097C28B /* BDDynamicTreeDemoTests */,
270 | );
271 | };
272 | /* End PBXProject section */
273 |
274 | /* Begin PBXResourcesBuildPhase section */
275 | 1AFB1F23198B9E5B0097C28B /* Resources */ = {
276 | isa = PBXResourcesBuildPhase;
277 | buildActionMask = 2147483647;
278 | files = (
279 | 1AFB1F70198B9F050097C28B /* 2.jpg in Resources */,
280 | 1AFB1F72198B9F050097C28B /* icon_plus@2x.png in Resources */,
281 | 1AFB1F6A198B9EC70097C28B /* BDDynamicTreeCell.xib in Resources */,
282 | 1AFB1F3F198B9E5B0097C28B /* Main_iPad.storyboard in Resources */,
283 | 1AFB1F44198B9E5B0097C28B /* Images.xcassets in Resources */,
284 | 1AFB1F3C198B9E5B0097C28B /* Main_iPhone.storyboard in Resources */,
285 | 1AFB1F33198B9E5B0097C28B /* InfoPlist.strings in Resources */,
286 | 1AFB1F71198B9F050097C28B /* icon_minus@2x.png in Resources */,
287 | );
288 | runOnlyForDeploymentPostprocessing = 0;
289 | };
290 | 1AFB1F47198B9E5B0097C28B /* Resources */ = {
291 | isa = PBXResourcesBuildPhase;
292 | buildActionMask = 2147483647;
293 | files = (
294 | 1AFB1F55198B9E5B0097C28B /* InfoPlist.strings in Resources */,
295 | );
296 | runOnlyForDeploymentPostprocessing = 0;
297 | };
298 | /* End PBXResourcesBuildPhase section */
299 |
300 | /* Begin PBXSourcesBuildPhase section */
301 | 1AFB1F21198B9E5B0097C28B /* Sources */ = {
302 | isa = PBXSourcesBuildPhase;
303 | buildActionMask = 2147483647;
304 | files = (
305 | 1AFB1F42198B9E5B0097C28B /* BDViewController.m in Sources */,
306 | 1AFB1F68198B9EC70097C28B /* BDDynamicTree.m in Sources */,
307 | 1AFB1F69198B9EC70097C28B /* BDDynamicTreeCell.m in Sources */,
308 | 1AFB1F6B198B9EC70097C28B /* BDDynamicTreeNode.m in Sources */,
309 | 1AFB1F39198B9E5B0097C28B /* BDAppDelegate.m in Sources */,
310 | 1AFB1F35198B9E5B0097C28B /* main.m in Sources */,
311 | );
312 | runOnlyForDeploymentPostprocessing = 0;
313 | };
314 | 1AFB1F45198B9E5B0097C28B /* Sources */ = {
315 | isa = PBXSourcesBuildPhase;
316 | buildActionMask = 2147483647;
317 | files = (
318 | 1AFB1F57198B9E5B0097C28B /* BDDynamicTreeDemoTests.m in Sources */,
319 | );
320 | runOnlyForDeploymentPostprocessing = 0;
321 | };
322 | /* End PBXSourcesBuildPhase section */
323 |
324 | /* Begin PBXTargetDependency section */
325 | 1AFB1F4F198B9E5B0097C28B /* PBXTargetDependency */ = {
326 | isa = PBXTargetDependency;
327 | target = 1AFB1F24198B9E5B0097C28B /* BDDynamicTreeDemo */;
328 | targetProxy = 1AFB1F4E198B9E5B0097C28B /* PBXContainerItemProxy */;
329 | };
330 | /* End PBXTargetDependency section */
331 |
332 | /* Begin PBXVariantGroup section */
333 | 1AFB1F31198B9E5B0097C28B /* InfoPlist.strings */ = {
334 | isa = PBXVariantGroup;
335 | children = (
336 | 1AFB1F32198B9E5B0097C28B /* en */,
337 | );
338 | name = InfoPlist.strings;
339 | sourceTree = "";
340 | };
341 | 1AFB1F3A198B9E5B0097C28B /* Main_iPhone.storyboard */ = {
342 | isa = PBXVariantGroup;
343 | children = (
344 | 1AFB1F3B198B9E5B0097C28B /* Base */,
345 | );
346 | name = Main_iPhone.storyboard;
347 | sourceTree = "";
348 | };
349 | 1AFB1F3D198B9E5B0097C28B /* Main_iPad.storyboard */ = {
350 | isa = PBXVariantGroup;
351 | children = (
352 | 1AFB1F3E198B9E5B0097C28B /* Base */,
353 | );
354 | name = Main_iPad.storyboard;
355 | sourceTree = "";
356 | };
357 | 1AFB1F53198B9E5B0097C28B /* InfoPlist.strings */ = {
358 | isa = PBXVariantGroup;
359 | children = (
360 | 1AFB1F54198B9E5B0097C28B /* en */,
361 | );
362 | name = InfoPlist.strings;
363 | sourceTree = "";
364 | };
365 | /* End PBXVariantGroup section */
366 |
367 | /* Begin XCBuildConfiguration section */
368 | 1AFB1F58198B9E5B0097C28B /* Debug */ = {
369 | isa = XCBuildConfiguration;
370 | buildSettings = {
371 | ALWAYS_SEARCH_USER_PATHS = NO;
372 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
373 | CLANG_CXX_LIBRARY = "libc++";
374 | CLANG_ENABLE_MODULES = YES;
375 | CLANG_ENABLE_OBJC_ARC = YES;
376 | CLANG_WARN_BOOL_CONVERSION = YES;
377 | CLANG_WARN_CONSTANT_CONVERSION = YES;
378 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
379 | CLANG_WARN_EMPTY_BODY = YES;
380 | CLANG_WARN_ENUM_CONVERSION = YES;
381 | CLANG_WARN_INT_CONVERSION = YES;
382 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
383 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
384 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
385 | COPY_PHASE_STRIP = NO;
386 | GCC_C_LANGUAGE_STANDARD = gnu99;
387 | GCC_DYNAMIC_NO_PIC = NO;
388 | GCC_OPTIMIZATION_LEVEL = 0;
389 | GCC_PREPROCESSOR_DEFINITIONS = (
390 | "DEBUG=1",
391 | "$(inherited)",
392 | );
393 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
394 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
395 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
396 | GCC_WARN_UNDECLARED_SELECTOR = YES;
397 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
398 | GCC_WARN_UNUSED_FUNCTION = YES;
399 | GCC_WARN_UNUSED_VARIABLE = YES;
400 | IPHONEOS_DEPLOYMENT_TARGET = 7.1;
401 | ONLY_ACTIVE_ARCH = YES;
402 | SDKROOT = iphoneos;
403 | TARGETED_DEVICE_FAMILY = "1,2";
404 | };
405 | name = Debug;
406 | };
407 | 1AFB1F59198B9E5B0097C28B /* Release */ = {
408 | isa = XCBuildConfiguration;
409 | buildSettings = {
410 | ALWAYS_SEARCH_USER_PATHS = NO;
411 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
412 | CLANG_CXX_LIBRARY = "libc++";
413 | CLANG_ENABLE_MODULES = YES;
414 | CLANG_ENABLE_OBJC_ARC = YES;
415 | CLANG_WARN_BOOL_CONVERSION = YES;
416 | CLANG_WARN_CONSTANT_CONVERSION = YES;
417 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
418 | CLANG_WARN_EMPTY_BODY = YES;
419 | CLANG_WARN_ENUM_CONVERSION = YES;
420 | CLANG_WARN_INT_CONVERSION = YES;
421 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
422 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
423 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
424 | COPY_PHASE_STRIP = YES;
425 | ENABLE_NS_ASSERTIONS = NO;
426 | GCC_C_LANGUAGE_STANDARD = gnu99;
427 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
428 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
429 | GCC_WARN_UNDECLARED_SELECTOR = YES;
430 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
431 | GCC_WARN_UNUSED_FUNCTION = YES;
432 | GCC_WARN_UNUSED_VARIABLE = YES;
433 | IPHONEOS_DEPLOYMENT_TARGET = 7.1;
434 | SDKROOT = iphoneos;
435 | TARGETED_DEVICE_FAMILY = "1,2";
436 | VALIDATE_PRODUCT = YES;
437 | };
438 | name = Release;
439 | };
440 | 1AFB1F5B198B9E5B0097C28B /* Debug */ = {
441 | isa = XCBuildConfiguration;
442 | buildSettings = {
443 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
444 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
445 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
446 | GCC_PREFIX_HEADER = "BDDynamicTreeDemo/BDDynamicTreeDemo-Prefix.pch";
447 | INFOPLIST_FILE = "BDDynamicTreeDemo/BDDynamicTreeDemo-Info.plist";
448 | IPHONEOS_DEPLOYMENT_TARGET = 6.1;
449 | PRODUCT_NAME = "$(TARGET_NAME)";
450 | WRAPPER_EXTENSION = app;
451 | };
452 | name = Debug;
453 | };
454 | 1AFB1F5C198B9E5B0097C28B /* Release */ = {
455 | isa = XCBuildConfiguration;
456 | buildSettings = {
457 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
458 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
459 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
460 | GCC_PREFIX_HEADER = "BDDynamicTreeDemo/BDDynamicTreeDemo-Prefix.pch";
461 | INFOPLIST_FILE = "BDDynamicTreeDemo/BDDynamicTreeDemo-Info.plist";
462 | IPHONEOS_DEPLOYMENT_TARGET = 6.1;
463 | PRODUCT_NAME = "$(TARGET_NAME)";
464 | WRAPPER_EXTENSION = app;
465 | };
466 | name = Release;
467 | };
468 | 1AFB1F5E198B9E5B0097C28B /* Debug */ = {
469 | isa = XCBuildConfiguration;
470 | buildSettings = {
471 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/BDDynamicTreeDemo.app/BDDynamicTreeDemo";
472 | FRAMEWORK_SEARCH_PATHS = (
473 | "$(SDKROOT)/Developer/Library/Frameworks",
474 | "$(inherited)",
475 | "$(DEVELOPER_FRAMEWORKS_DIR)",
476 | );
477 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
478 | GCC_PREFIX_HEADER = "BDDynamicTreeDemo/BDDynamicTreeDemo-Prefix.pch";
479 | GCC_PREPROCESSOR_DEFINITIONS = (
480 | "DEBUG=1",
481 | "$(inherited)",
482 | );
483 | INFOPLIST_FILE = "BDDynamicTreeDemoTests/BDDynamicTreeDemoTests-Info.plist";
484 | PRODUCT_NAME = "$(TARGET_NAME)";
485 | TEST_HOST = "$(BUNDLE_LOADER)";
486 | WRAPPER_EXTENSION = xctest;
487 | };
488 | name = Debug;
489 | };
490 | 1AFB1F5F198B9E5B0097C28B /* Release */ = {
491 | isa = XCBuildConfiguration;
492 | buildSettings = {
493 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/BDDynamicTreeDemo.app/BDDynamicTreeDemo";
494 | FRAMEWORK_SEARCH_PATHS = (
495 | "$(SDKROOT)/Developer/Library/Frameworks",
496 | "$(inherited)",
497 | "$(DEVELOPER_FRAMEWORKS_DIR)",
498 | );
499 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
500 | GCC_PREFIX_HEADER = "BDDynamicTreeDemo/BDDynamicTreeDemo-Prefix.pch";
501 | INFOPLIST_FILE = "BDDynamicTreeDemoTests/BDDynamicTreeDemoTests-Info.plist";
502 | PRODUCT_NAME = "$(TARGET_NAME)";
503 | TEST_HOST = "$(BUNDLE_LOADER)";
504 | WRAPPER_EXTENSION = xctest;
505 | };
506 | name = Release;
507 | };
508 | /* End XCBuildConfiguration section */
509 |
510 | /* Begin XCConfigurationList section */
511 | 1AFB1F20198B9E5B0097C28B /* Build configuration list for PBXProject "BDDynamicTreeDemo" */ = {
512 | isa = XCConfigurationList;
513 | buildConfigurations = (
514 | 1AFB1F58198B9E5B0097C28B /* Debug */,
515 | 1AFB1F59198B9E5B0097C28B /* Release */,
516 | );
517 | defaultConfigurationIsVisible = 0;
518 | defaultConfigurationName = Release;
519 | };
520 | 1AFB1F5A198B9E5B0097C28B /* Build configuration list for PBXNativeTarget "BDDynamicTreeDemo" */ = {
521 | isa = XCConfigurationList;
522 | buildConfigurations = (
523 | 1AFB1F5B198B9E5B0097C28B /* Debug */,
524 | 1AFB1F5C198B9E5B0097C28B /* Release */,
525 | );
526 | defaultConfigurationIsVisible = 0;
527 | };
528 | 1AFB1F5D198B9E5B0097C28B /* Build configuration list for PBXNativeTarget "BDDynamicTreeDemoTests" */ = {
529 | isa = XCConfigurationList;
530 | buildConfigurations = (
531 | 1AFB1F5E198B9E5B0097C28B /* Debug */,
532 | 1AFB1F5F198B9E5B0097C28B /* Release */,
533 | );
534 | defaultConfigurationIsVisible = 0;
535 | };
536 | /* End XCConfigurationList section */
537 | };
538 | rootObject = 1AFB1F1D198B9E5B0097C28B /* Project object */;
539 | }
540 |
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo.xcodeproj/xcuserdata/gaoruiqiang.xcuserdatad/xcschemes/BDDynamicTreeDemo.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
61 |
62 |
68 |
69 |
70 |
71 |
72 |
73 |
79 |
80 |
86 |
87 |
88 |
89 |
91 |
92 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo.xcodeproj/xcuserdata/gaoruiqiang.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | BDDynamicTreeDemo.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 1AFB1F24198B9E5B0097C28B
16 |
17 | primary
18 |
19 |
20 | 1AFB1F48198B9E5B0097C28B
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo/BDAppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // BDAppDelegate.h
3 | // BDDynamicTreeDemo
4 | //
5 | // Created by Scott Ban on 14-8-1.
6 | // Copyright (c) 2014年 Scott Ban. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface BDAppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo/BDAppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // BDAppDelegate.m
3 | // BDDynamicTreeDemo
4 | //
5 | // Created by Scott Ban on 14-8-1.
6 | // Copyright (c) 2014年 Scott Ban. All rights reserved.
7 | //
8 |
9 | #import "BDAppDelegate.h"
10 |
11 | @implementation BDAppDelegate
12 |
13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
14 | {
15 | // Override point for customization after application launch.
16 | return YES;
17 | }
18 |
19 | - (void)applicationWillResignActive:(UIApplication *)application
20 | {
21 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
23 | }
24 |
25 | - (void)applicationDidEnterBackground:(UIApplication *)application
26 | {
27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
29 | }
30 |
31 | - (void)applicationWillEnterForeground:(UIApplication *)application
32 | {
33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
34 | }
35 |
36 | - (void)applicationDidBecomeActive:(UIApplication *)application
37 | {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application
42 | {
43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo/BDDynamicTreeDemo-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | Scott-Ban.${PRODUCT_NAME:rfc1034identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UIMainStoryboardFile
28 | Main_iPhone
29 | UIMainStoryboardFile~ipad
30 | Main_iPad
31 | UIRequiredDeviceCapabilities
32 |
33 | armv7
34 |
35 | UISupportedInterfaceOrientations
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationLandscapeLeft
39 | UIInterfaceOrientationLandscapeRight
40 |
41 | UISupportedInterfaceOrientations~ipad
42 |
43 | UIInterfaceOrientationPortrait
44 | UIInterfaceOrientationPortraitUpsideDown
45 | UIInterfaceOrientationLandscapeLeft
46 | UIInterfaceOrientationLandscapeRight
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo/BDDynamicTreeDemo-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #import
8 |
9 | #ifndef __IPHONE_5_0
10 | #warning "This project uses features only available in iOS SDK 5.0 and later."
11 | #endif
12 |
13 | #ifdef __OBJC__
14 | #import
15 | #import
16 | #endif
17 |
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo/BDViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // BDViewController.h
3 | //
4 | // Created by Scott Ban (https://github.com/reference) on 14/07/30.
5 | // Copyright (C) 2011-2020 by Scott Ban
6 |
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #import
26 | #import "BDDynamicTree.h"
27 |
28 | @interface BDViewController : UIViewController
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo/BDViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // BDViewController.m
3 | //
4 | // Created by Scott Ban (https://github.com/reference) on 14/07/30.
5 | // Copyright (C) 2011-2020 by Scott Ban
6 |
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #import "BDViewController.h"
26 | #import "BDDynamicTreeNode.h"
27 |
28 | @interface BDViewController ()
29 | {
30 | BDDynamicTree *_dynamicTree;
31 | }
32 | @end
33 |
34 | @implementation BDViewController
35 |
36 | - (void)viewDidLoad
37 | {
38 | [super viewDidLoad];
39 |
40 | _dynamicTree = [[BDDynamicTree alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height - 20) nodes:[self generateData]];
41 | _dynamicTree.delegate = self;
42 | [self.view addSubview:_dynamicTree];
43 | }
44 |
45 | - (NSArray *)generateData
46 | {
47 | NSMutableArray *arr = [NSMutableArray array];
48 |
49 | //北京大洋国际科技有限公司
50 | BDDynamicTreeNode *root = [[BDDynamicTreeNode alloc] init];
51 | root.originX = 20.f;
52 | root.isDepartment = YES;
53 | root.fatherNodeId = nil;
54 | root.nodeId = @"node_1000";
55 | root.name = @"北京大洋国际科技有限公司";
56 | root.data = @{@"name":@"北京大洋国际科技有限公司"};
57 |
58 | [arr addObject:root];
59 |
60 | //财务部
61 | BDDynamicTreeNode *caiwu = [[BDDynamicTreeNode alloc] init];
62 | caiwu.isDepartment = YES;
63 | caiwu.fatherNodeId = @"node_1000";
64 | caiwu.nodeId = @"node_1100";
65 | caiwu.name = @"财务部";
66 | caiwu.data = @{@"name":@"财务部"};
67 |
68 | [arr addObject:caiwu];
69 |
70 | //市场部
71 | BDDynamicTreeNode *shichang = [[BDDynamicTreeNode alloc] init];
72 | shichang.isDepartment = YES;
73 | shichang.fatherNodeId = @"node_1000";
74 | shichang.nodeId = @"node_1200";
75 | shichang.name = @"市场部";
76 | shichang.data = @{@"name":@"市场部"};
77 |
78 | [arr addObject:shichang];
79 |
80 | //出纳部
81 | BDDynamicTreeNode *chuna = [[BDDynamicTreeNode alloc] init];
82 | chuna.isDepartment = YES;
83 | chuna.fatherNodeId = @"node_1100";
84 | chuna.nodeId = @"node_1110";
85 | chuna.name = @"出纳部";
86 | chuna.data = @{@"name":@"出纳部"};
87 |
88 | [arr addObject:chuna];
89 |
90 | //收银部
91 | BDDynamicTreeNode *shouyin = [[BDDynamicTreeNode alloc] init];
92 | shouyin.isDepartment = YES;
93 | shouyin.fatherNodeId = @"node_1100";
94 | shouyin.nodeId = @"node_1120";
95 | shouyin.name = @"收银部";
96 | shouyin.data = @{@"name":@"收银部"};
97 |
98 | [arr addObject:shouyin];
99 |
100 | //xiao娟
101 | BDDynamicTreeNode *lujuan = [[BDDynamicTreeNode alloc] init];
102 | lujuan.isDepartment = NO;
103 | lujuan.fatherNodeId = @"node_1120";
104 | lujuan.nodeId = @"node_1121";
105 | lujuan.name = @"小娟";
106 | lujuan.data = @{@"name":@"小娟",@"avatarUrl":@"http://www.baidu.com/lujuan.jpg"};
107 |
108 | [arr addObject:lujuan];
109 |
110 | //涛哥
111 | BDDynamicTreeNode *taoge = [[BDDynamicTreeNode alloc] init];
112 | taoge.isDepartment = NO;
113 | taoge.fatherNodeId = @"node_1120";
114 | taoge.nodeId = @"node_1122";
115 | taoge.name = @"涛哥";
116 | taoge.data = @{@"name":@"涛哥",@"avatarUrl":@"http://www.baidu.com/lujuan.jpg"};
117 |
118 | [arr addObject:taoge];
119 |
120 | return arr;
121 | }
122 |
123 | - (void)dynamicTree:(BDDynamicTree *)dynamicTree didSelectedRowWithNode:(BDDynamicTreeNode *)node
124 | {
125 | if (!node.isDepartment) {
126 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"你好,我的名字叫"
127 | message:node.name
128 | delegate:nil
129 | cancelButtonTitle:nil
130 | otherButtonTitles:@"知道了", nil];
131 | [alert show];
132 | }
133 | }
134 |
135 | @end
136 |
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo/Base.lproj/Main_iPad.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo/Base.lproj/Main_iPhone.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "40x40",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "60x60",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "ipad",
20 | "size" : "29x29",
21 | "scale" : "1x"
22 | },
23 | {
24 | "idiom" : "ipad",
25 | "size" : "29x29",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "ipad",
30 | "size" : "40x40",
31 | "scale" : "1x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "40x40",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "76x76",
41 | "scale" : "1x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "76x76",
46 | "scale" : "2x"
47 | }
48 | ],
49 | "info" : {
50 | "version" : 1,
51 | "author" : "xcode"
52 | }
53 | }
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "7.0",
8 | "scale" : "2x"
9 | },
10 | {
11 | "orientation" : "portrait",
12 | "idiom" : "iphone",
13 | "subtype" : "retina4",
14 | "extent" : "full-screen",
15 | "minimum-system-version" : "7.0",
16 | "scale" : "2x"
17 | },
18 | {
19 | "orientation" : "portrait",
20 | "idiom" : "ipad",
21 | "extent" : "full-screen",
22 | "minimum-system-version" : "7.0",
23 | "scale" : "1x"
24 | },
25 | {
26 | "orientation" : "landscape",
27 | "idiom" : "ipad",
28 | "extent" : "full-screen",
29 | "minimum-system-version" : "7.0",
30 | "scale" : "1x"
31 | },
32 | {
33 | "orientation" : "portrait",
34 | "idiom" : "ipad",
35 | "extent" : "full-screen",
36 | "minimum-system-version" : "7.0",
37 | "scale" : "2x"
38 | },
39 | {
40 | "orientation" : "landscape",
41 | "idiom" : "ipad",
42 | "extent" : "full-screen",
43 | "minimum-system-version" : "7.0",
44 | "scale" : "2x"
45 | }
46 | ],
47 | "info" : {
48 | "version" : 1,
49 | "author" : "xcode"
50 | }
51 | }
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo/Resources/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reference/BDDynamicTree/1f0e3c8cf5e1931aef3fbef352bfc1d3f0f72c6f/BDDynamicTreeDemo/BDDynamicTreeDemo/Resources/2.jpg
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo/Resources/icon_minus@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reference/BDDynamicTree/1f0e3c8cf5e1931aef3fbef352bfc1d3f0f72c6f/BDDynamicTreeDemo/BDDynamicTreeDemo/Resources/icon_minus@2x.png
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo/Resources/icon_plus@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reference/BDDynamicTree/1f0e3c8cf5e1931aef3fbef352bfc1d3f0f72c6f/BDDynamicTreeDemo/BDDynamicTreeDemo/Resources/icon_plus@2x.png
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // BDDynamicTreeDemo
4 | //
5 | // Created by Scott Ban on 14-8-1.
6 | // Copyright (c) 2014年 Scott Ban. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "BDAppDelegate.h"
12 |
13 | int main(int argc, char * argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([BDAppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemoTests/BDDynamicTreeDemoTests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | Scott-Ban.${PRODUCT_NAME:rfc1034identifier}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemoTests/BDDynamicTreeDemoTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // BDDynamicTreeDemoTests.m
3 | // BDDynamicTreeDemoTests
4 | //
5 | // Created by Scott Ban on 14-8-1.
6 | // Copyright (c) 2014年 Scott Ban. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface BDDynamicTreeDemoTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation BDDynamicTreeDemoTests
16 |
17 | - (void)setUp
18 | {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown
24 | {
25 | // Put teardown code here. This method is called after the invocation of each test method in the class.
26 | [super tearDown];
27 | }
28 |
29 | - (void)testExample
30 | {
31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/BDDynamicTreeDemo/BDDynamicTreeDemoTests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | BDDynamicTree
2 | =============
3 |
4 | 动态树形结构菜单
5 |
6 | 功能
7 | ====
8 | 实现任意多层的树形菜单结构,简单方便,配置轻松。
9 |
10 | ScreenShot
11 | =========
12 |
13 |
--------------------------------------------------------------------------------