折叠cell
在暑假任务3Gshare中用到了折叠cell;
具体效果如下:


首先设定两个属性为:tableView和存储cell的元素数据的可变数组。
@interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableview1;
@property (nonatomic, strong) NSMutableArray *array;
@end
然后对两个属性进行初始化,注意对tableView1的tag只进行设定,从而通过tag的值来判断cell的展开还是收缩状态。
self.tableview1 = [[UITableView alloc] initWithFrame:CGRectMake(100, 100, 430 - 200, 100)];
self.tableview1.delegate = self;
self.tableview1.dataSource = self;
self.tableview1.tag = 0;
[self.tableview1 registerClass:[UITableViewCell class] forCellReuseIdentifier:@"1"];
[self.view addSubview:_tableview1];
_array = [NSMutableArray arrayWithObjects:@"原创作品",@"设计教程",@"设计资料",@"设计师观点", nil];
然后要完成tableView的协议函数:
//获取每组单元格的个数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (_tableview1.tag == 0) {
return 1;
} else {
return 4<



被折叠的 条评论
为什么被折叠?



