iOS 开发-数组反向显示于 tableView。

来源:互联网 发布:淘宝客拉人宣传单 编辑:程序博客网 时间:2024/06/05 10:36

效果类似 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

0 0
原创粉丝点击