【发布时间】:2016-01-29 03:08:39
【问题描述】:
关于UITableView重用,当有多个不同的Cell时,用不同的标识符区分好还是用一个标识符和Cell子Views remove,重新添加内容好,如果Cell很多的情况下,这些可重用的,什么样的具体的访问规则,当一个标识符在队列上的位置是如何去掉的高手解答,谢谢
_testTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
_testTableView.dataSource = self;
_testTableView.delegate = self;
[_testTableView setRowHeight:80.];
[self.view addSubview:_testTableView];
[_testTableView registerClass:[TestTableViewCell class] forCellReuseIdentifier:testKeyOne];
[_testTableView registerClass:[TestTwoTableViewCell class] forCellReuseIdentifier:testKeyTwo];
//一种方式 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//one
if(indexPath.row < 15){
TestTableViewCell * oneCell = [tableView dequeueReusableCellWithIdentifier:testKeyOne forIndexPath:indexPath];
return oneCell;
}else{
TestTwoTableViewCell * oneCell = [tableView dequeueReusableCellWithIdentifier:testKeyTwo forIndexPath:indexPath];
return oneCell;
}
return nil;
}
两种方式:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:testKeyOne forIndexPath:indexPath];
for(UIView * view in cell.subviews){
[view removeFromSuperview];
}
//[cell addSubview:];
return cell;
}
一种或两种,或者其他更好的方式,以及原本特定的重用,进入重用并取出队列顺序的顺序
【问题讨论】:
-
请正确解释,你到底想做什么......
-
对不起,我没看懂你的问题,请把你的问题说清楚,并请使用标点符号(例如问号)。
标签: ios uitableview