【发布时间】:2011-08-18 19:40:23
【问题描述】:
我有一个 uitableview 的单元格,其行为取决于什么:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 2) {
do x;
}else{
do y;
}
}
当您处理单个表时,它有点工作,但是当您尝试添加部分或子类时,这种类型的“幻数”很容易破坏。
我的问题是,是否可以“标记”该部分?所以我们不做section==1,而是做:
indexPath.section.tag=="user_stats" {load x}
indexPath.section.tag=="answers" {show answers}
indexPath.section.tag=="page" {show pagination}
【问题讨论】:
标签: iphone objective-c uitableview