【发布时间】:2013-05-06 12:23:06
【问题描述】:
如果我有一个 UITableView,它有 [arrayofStudents count] 部分:
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [arrayofStudents count]
}
然后我想为每个部分做一个标题标题(注意部分的数量与arrayofStudent的大小有关)
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
switch (section) {
case //if it is the first section :
return [arrayofStudents objectAtIndex:0];
break;
case //if it is the second section:
return [arrayofStudents objectAtIndex:1];
break;
//case until arrive to the count of arrayofStudents
default:
break;
}
case 语句的数量与 arrayofStudents 的数量有关,如果我在 arrayofStudents 中有 10 个元素,那么我将有 10 个部分。 如何在 switch case 语句中构建它?
感谢您的帮助。
【问题讨论】:
标签: ios uitableview ios6 switch-statement