效果类似 iOS 上的系统秒表功能下的 tableView 显示方式。
代码如下
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *Identifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:Identifier];
}
cell.textLabel.text = [self.timelist objectAtIndex:[self.timelist count]-indexPath.row-1];
return cell;
}
其中:
cell.textLabel.text = [self.timelist objectAtIndex:[self.timelist count]-indexPath.row-1];为关键代码。
将对象下标设置为数组的数量减去位置下标减1
本文介绍了一种模仿iOS系统秒表中TableView显示效果的方法。通过逆序展示数组元素,实现了与iOS秒表相似的界面布局。核心代码展示了如何根据TableView的indexPath调整timelist数组的显示顺序。
406

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



